def test_bad_request_error(req, msg):
inbound = HTTPInbound()
inbound.start(None)
client = AsyncHTTPClient()
req.url = 'http://localhost:%s' % inbound.port
req.method = 'POST'
req.body = ''
with pytest.raises(HTTPError) as e:
yield client.fetch(req)
e = e.value
assert e.code >= 400 and e.code <= 500
assert e.response.body == msg
评论列表
文章目录