mirror of
https://github.com/kennethreitz/requests.git
synced 2026-06-05 22:50:18 +00:00
Add ability to pass response to HTTPError()
Just a little refactoring, but it seems nicer to me to be able to pass the response when constructing the `HTTPError` instance instead of constructing it and then changing the member variable.
This commit is contained in:
+11
-1
@@ -385,7 +385,17 @@ class RequestsTestCase(unittest.TestCase):
|
||||
|
||||
# undo monkey patch
|
||||
HTTPConnectionPool.urlopen = old_urlopen
|
||||
|
||||
|
||||
def test_http_error(self):
|
||||
error = requests.exceptions.HTTPError()
|
||||
self.assertEqual(error.response, None)
|
||||
response = requests.Response()
|
||||
error = requests.exceptions.HTTPError(response=response)
|
||||
self.assertEqual(error.response, response)
|
||||
error = requests.exceptions.HTTPError('message', response=response)
|
||||
self.assertEqual(str(error), 'message')
|
||||
self.assertEqual(error.response, response)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
||||
Reference in New Issue
Block a user