git » kxd » commit 673ecd2

tests: Add missing conn.getresponse() which was causing false negatives

author Alberto Bertogli
2020-03-29 10:40:46 UTC
committer Alberto Bertogli
2020-03-29 10:40:46 UTC
parent c7e2e63f185e3ff5f463ef02909164e047ad3a72

tests: Add missing conn.getresponse() which was causing false negatives

Somewhere around Python 3.8, http.client.HTTPConnection objects changed
how result handling was done, and ignored SSL errors until
.getresponse() was called.

This causes the test_no_local_cert to fail, even though the server is
responding correctly.

This patch fixes this by adding a .getresponse() call, which forces
validation of the result and makes the test pass again.

tests/run_tests +1 -0

diff --git a/tests/run_tests b/tests/run_tests
index d6d4ba2..9499bfe 100755
--- a/tests/run_tests
+++ b/tests/run_tests
@@ -407,6 +407,7 @@ class TrickyRequests(TestCase):
         conn = self.https_connection("localhost", 19840)
         try:
             conn.request("GET", "/v1/")
+            conn.getresponse()
             conn.close()
         except ssl.SSLError as err:
             self.assertEqual(err.reason, "SSLV3_ALERT_BAD_CERTIFICATE")