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'
评论列表
文章目录