当前位置: 首页>>代码示例>>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;未经允许,请勿转载。