def test_async_fetch_with_error(self):
curl = CurlStub(b"result", {pycurl.HTTP_CODE: 501})
d = fetch_async("http://example.com/", curl=curl)
def got_error(failure):
self.assertEqual(failure.value.http_code, 501)
self.assertEqual(failure.value.body, b"result")
return failure
d.addErrback(got_error)
self.assertFailure(d, HTTPCodeError)
return d
评论列表
文章目录