]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
bpo-44022: Improve the regression test. (GH-26503) (#26506)
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Mon, 12 Jul 2021 15:09:01 +0000 (08:09 -0700)
committerGitHub <noreply@github.com>
Mon, 12 Jul 2021 15:09:01 +0000 (17:09 +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>
Lib/test/test_httplib.py

index 862a0970315d8a151f93d4e141d8d48f9bb475f9..c65fff0581b95a5d01517de5927f4e24945f23f0 100644 (file)
@@ -1009,7 +1009,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 = (