本文整理汇总了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
示例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
示例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
示例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)
示例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
示例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)
)
示例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,
),
)
示例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),
)