From f30675969d954f3662d925819d0f400da41b54e1 Mon Sep 17 00:00:00 2001 From: ai-bot Date: Thu, 1 Oct 2026 13:00:35 +0000 Subject: [PATCH] Close HTTPError response in route test --- tests/test_app.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/tests/test_app.py b/tests/test_app.py index 482b36c..fcbfd6c 100644 --- a/tests/test_app.py +++ b/tests/test_app.py @@ -40,9 +40,15 @@ class AppHandlerTests(unittest.TestCase): self.assertNotIn("Ã…rleg", body) def test_unknown_path_returns_not_found(self): - with self.assertRaises(HTTPError) as error: - urlopen(f"{self.base_url}/missing") - self.assertEqual(error.exception.code, 404) + try: + with urlopen(f"{self.base_url}/missing") as response: + self.fail(f"Expected 404, received {response.status}") + except HTTPError as error: + try: + self.assertEqual(error.code, 404) + error.read() + finally: + error.close() if __name__ == "__main__":