[util] add __enter__ & __exit__ methods to NullResponse (#8227)
This commit is contained in:
@@ -641,6 +641,12 @@ class NullResponse():
|
||||
self.url = url
|
||||
self.reason = str(reason)
|
||||
|
||||
def __enter__(self):
|
||||
return self
|
||||
|
||||
def __exit__(self, exc_type, exc_value, traceback):
|
||||
pass
|
||||
|
||||
def __str__(self):
|
||||
return "900 " + self.reason
|
||||
|
||||
|
||||
@@ -1041,6 +1041,9 @@ value = 123
|
||||
self.assertEqual(response.links.get("next"), None)
|
||||
self.assertEqual(response.close(), None)
|
||||
|
||||
with response as ctx:
|
||||
self.assertIs(response, ctx)
|
||||
|
||||
|
||||
class TestExtractor():
|
||||
category = "test_category"
|
||||
|
||||
Reference in New Issue
Block a user