當前位置: 首頁>>代碼示例>>Python>>正文


Python fields.Raw方法代碼示例

本文整理匯總了Python中marshmallow.fields.Raw方法的典型用法代碼示例。如果您正苦於以下問題:Python fields.Raw方法的具體用法?Python fields.Raw怎麽用?Python fields.Raw使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在marshmallow.fields的用法示例。


在下文中一共展示了fields.Raw方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: field_factory

# 需要導入模塊: from marshmallow import fields [as 別名]
# 或者: from marshmallow.fields import Raw [as 別名]
def field_factory(self, target: type) -> Callable[[FieldFactory], FieldFactory]:
        """
        Decorator form of register::

            @register.field_factor(bytes)
            def custom(converter, subtypes, opts):
                return fields.Raw(**opts)

        Returns the original function so it can be used again if needed.
        """

        def field_factory(constructor: FieldFactory) -> FieldFactory:
            self.register(target, constructor)
            return constructor

        return field_factory 
開發者ID:justanr,項目名稱:marshmallow-annotations,代碼行數:18,代碼來源:base.py

示例2: test_make_type_mapper_works_with_required

# 需要導入模塊: from marshmallow import fields [as 別名]
# 或者: from marshmallow.fields import Raw [as 別名]
def test_make_type_mapper_works_with_required():
    from flask_accepts.utils import make_type_mapper

    app = Flask(__name__)
    api = Api(app)

    mapper = make_type_mapper(fr.Raw)
    result = mapper(ma.Raw(required=True), api=api, model_name="test_model_name", operation="load")
    assert result.required 
開發者ID:apryor6,項目名稱:flask_accepts,代碼行數:11,代碼來源:utils_test.py

示例3: test_make_type_mapper_produces_nonrequired_param_by_default

# 需要導入模塊: from marshmallow import fields [as 別名]
# 或者: from marshmallow.fields import Raw [as 別名]
def test_make_type_mapper_produces_nonrequired_param_by_default():
    from flask_accepts.utils import make_type_mapper

    app = Flask(__name__)
    api = Api(app)

    mapper = make_type_mapper(fr.Raw)
    result = mapper(ma.Raw(), api=api, model_name="test_model_name", operation="load")
    assert not result.required 
開發者ID:apryor6,項目名稱:flask_accepts,代碼行數:11,代碼來源:utils_test.py

示例4: test_map_type_dump_ma_method_returns_fr_raw

# 需要導入模塊: from marshmallow import fields [as 別名]
# 或者: from marshmallow.fields import Raw [as 別名]
def test_map_type_dump_ma_method_returns_fr_raw():
    class TestSchema(Schema):
        method_field = ma.Method()

    TestApi = Api()

    expected_method_field_mapping = fr.Raw
    map_result = utils.map_type(TestSchema, TestApi, 'TestSchema','dump')

    assert isinstance(map_result['method_field'], expected_method_field_mapping) 
開發者ID:apryor6,項目名稱:flask_accepts,代碼行數:12,代碼來源:utils_test.py

示例5: register

# 需要導入模塊: from marshmallow import fields [as 別名]
# 或者: from marshmallow.fields import Raw [as 別名]
def register(self, target: type, constructor: FieldFactory) -> None:
        """
        Registers a raw field factory for the specified type::

            from marshmallow import fields

            def custom(converter, subtypes, opts):
                return fields.Raw(**opts)

            registry.register(bytes, custom)


        """
        pass 
開發者ID:justanr,項目名稱:marshmallow-annotations,代碼行數:16,代碼來源:base.py

示例6: test_any

# 需要導入模塊: from marshmallow import fields [as 別名]
# 或者: from marshmallow.fields import Raw [as 別名]
def test_any(self):
        self.assertFieldsEqual(
            field_for_schema(Any), fields.Raw(required=True, allow_none=True)
        ) 
開發者ID:lovasoa,項目名稱:marshmallow_dataclass,代碼行數:6,代碼來源:test_field_for_schema.py

示例7: test_builtin_dict

# 需要導入模塊: from marshmallow import fields [as 別名]
# 或者: from marshmallow.fields import Raw [as 別名]
def test_builtin_dict(self):
        self.assertFieldsEqual(
            field_for_schema(dict),
            fields.Dict(
                keys=fields.Raw(required=True, allow_none=True),
                values=fields.Raw(required=True, allow_none=True),
                required=True,
            ),
        ) 
開發者ID:lovasoa,項目名稱:marshmallow_dataclass,代碼行數:11,代碼來源:test_field_for_schema.py

示例8: test_builtin_list

# 需要導入模塊: from marshmallow import fields [as 別名]
# 或者: from marshmallow.fields import Raw [as 別名]
def test_builtin_list(self):
        self.assertFieldsEqual(
            field_for_schema(list, metadata=dict(required=False)),
            fields.List(fields.Raw(required=True, allow_none=True), required=False),
        ) 
開發者ID:lovasoa,項目名稱:marshmallow_dataclass,代碼行數:7,代碼來源:test_field_for_schema.py


注:本文中的marshmallow.fields.Raw方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。