bpo-44022: Improve the regression test. (GH-26503)
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Thu, 3 Jun 2021 04:10:22 +0000 (21:10 -0700)
committerAdrian Bunk <bunk@debian.org>
Sun, 1 Dec 2024 12:12:57 +0000 (14:12 +0200)
It wasn't actually detecting the regression due to the
assertion being too lenient.
(cherry picked from commit e60ab843cbb016fb6ff8b4f418641ac05a9b2fcc)

Co-authored-by: Gregory P. Smith <greg@krypto.org>
Gbp-Pq: Name 0006-bpo-44022-Improve-the-regression-test.-GH-26503.patch

Lib/test/test_httplib.py

index 8304d5834891cd5ac9956c0df92d9668c9286848..0e042319a28c11d81b9dfc473d77f5093d4ee61f 100644 (file)
@@ -1010,7 +1010,12 @@ class BasicTest(TestCase):
             'r\n' * 32768
         )
         resp = client.HTTPResponse(FakeSocket(body))
-        self.assertRaises(client.HTTPException, resp.begin)
+        with self.assertRaises(client.HTTPException) as cm:
+            resp.begin()
+        # We must assert more because other reasonable errors that we
+        # do not want can also be HTTPException derived.
+        self.assertIn('got more than ', str(cm.exception))
+        self.assertIn('headers', str(cm.exception))
 
     def test_overflowing_chunked_line(self):
         body = (