test_swagger_spec.py 文件源码

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

项目:klue-client-server 作者: erwan-lemonnier 项目源码 文件源码
def test_model_to_json(self):
        swagger_dict = yaml.load(Tests.yaml_complex_model)
        spec = ApiSpec(swagger_dict)

        Foo = spec.definitions['Foo']
        Bar = spec.definitions['Bar']

        f = Foo(
            token='abcd',
            bar=Bar(
                a=1,
                b=date.today()
            )
        )

        print("foo: " + pprint.pformat(f))

        j = spec.model_to_json(f)
        self.assertDictEqual(j, {
            'token': 'abcd',
            'bar': {
                'a': 1,
                'b': date.today().isoformat()
            }
        })
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号