From: Gregory P. Smith Date: Thu, 3 Jun 2021 03:43:38 +0000 (-0700) Subject: bpo-44022: Improve the regression test. (GH-26503) X-Git-Tag: v3.11.0a1~962 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=e60ab843cbb016fb6ff8b4f418641ac05a9b2fcc;p=thirdparty%2FPython%2Fcpython.git bpo-44022: Improve the regression test. (GH-26503) It wasn't actually detecting the regression due to the assertion being too lenient. --- diff --git a/Lib/test/test_httplib.py b/Lib/test/test_httplib.py index e9272569ecc5..8265b8d1d6d2 100644 --- a/Lib/test/test_httplib.py +++ b/Lib/test/test_httplib.py @@ -1186,7 +1186,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 = (