test_encoding.py 文件源码

python
阅读 31 收藏 0 点赞 0 评论 0

项目:queue-messaging 作者: socialwifi 项目源码 文件源码
def test_if_encode_raises_exception_with_invalid_data_and_strict_schema():
    class StrictSchema(marshmallow.Schema):
        uuid_field = fields.UUID(required=True)

        class Meta:
            strict = True

    class Event(structures.Model):
        class Meta:
            schema = StrictSchema
            type_name = 'Event'

    data = Event(uuid_field='not an uuid')
    with pytest.raises(exceptions.EncodingError) as excinfo:
        encoding.encode(data)
    assert str(excinfo.value) == (
        "({'uuid_field': ['Not a valid UUID.']}, '')")
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号