test_encoding.py 文件源码

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

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

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

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


问题


面经


文章

微信
公众号

扫码关注公众号