python类Method()的实例源码

test_schema.py 文件源码 项目:microcosm-flask 作者: globality-corp 项目源码 文件源码 阅读 34 收藏 0 点赞 0 评论 0
def test_field_decorated_method():
    parameter = build_parameter(TestSchema().fields["decorated"])
    assert_that(parameter, is_(equal_to({
        # NB: default for `fields.Method` is "object"
        "type": "string",
    })))
test_jit.py 文件源码 项目:toasted-marshmallow 作者: lyft 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
def schema():
    class BasicSchema(Schema):
        class Meta:
            ordered = True
        foo = fields.Integer(attribute='@#')
        bar = fields.String()
        raz = fields.Method('raz_')
        meh = fields.String(load_only=True)
        blargh = fields.Boolean()

        def raz_(self, obj):
            return 'Hello!'
    return BasicSchema()


问题


面经


文章

微信
公众号

扫码关注公众号