[util] add __enter__ & __exit__ methods to NullResponse (#8227)

This commit is contained in:
Mike Fährmann
2025-09-17 09:05:44 +02:00
parent 5aa2124736
commit a16238edda
2 changed files with 9 additions and 0 deletions

View File

@@ -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

View File

@@ -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"