test_negotiation.py 文件源码

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

项目:bottlecap 作者: foxx 项目源码 文件源码
def test_dispatch_error(self, app, view_render_errors):
        """Dispatch raises an HTTPError"""

        @app.routecv
        class ExampleView(ExampleErrorView):
            render_errors = view_render_errors
            renderer_classes = [JSONRenderer]

        resp = app.webtest.get('/error',
            expect_errors=True)

        if view_render_errors:
            assert resp.status == '418 Teapot'
            assert resp.body == b'[1, 2, 3]'
            assert resp.headers['Content-Type'] == 'application/json'
        else:
            assert resp.status == '418 Teapot'
            assert b'DOCTYPE HTML PUBLIC' in resp.body
            assert resp.headers['Content-Type'] == 'text/html; charset=UTF-8'
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号