]> granicus.if.org Git - python/commitdiff
Issue 28022: Catch deprecation warning in test_httplib, reported by Martin Panter
authorChristian Heimes <christian@python.org>
Sun, 11 Sep 2016 17:54:43 +0000 (19:54 +0200)
committerChristian Heimes <christian@python.org>
Sun, 11 Sep 2016 17:54:43 +0000 (19:54 +0200)
Lib/test/test_httplib.py

index 3fc02ea01a44d5800766c5f0dd70749eda3bb4dd..c613c57723d33e07a90b6366383a2f01f285f054 100644 (file)
@@ -1642,14 +1642,16 @@ class HTTPSTest(TestCase):
         with self.assertRaises(ssl.CertificateError):
             h.request('GET', '/')
         # Same with explicit check_hostname=True
-        h = client.HTTPSConnection('localhost', server.port, context=context,
-                                   check_hostname=True)
+        with support.check_warnings(('', DeprecationWarning)):
+            h = client.HTTPSConnection('localhost', server.port,
+                                       context=context, check_hostname=True)
         with self.assertRaises(ssl.CertificateError):
             h.request('GET', '/')
         # With check_hostname=False, the mismatching is ignored
         context.check_hostname = False
-        h = client.HTTPSConnection('localhost', server.port, context=context,
-                                   check_hostname=False)
+        with support.check_warnings(('', DeprecationWarning)):
+            h = client.HTTPSConnection('localhost', server.port,
+                                       context=context, check_hostname=False)
         h.request('GET', '/nonexistent')
         resp = h.getresponse()
         resp.close()
@@ -1666,8 +1668,9 @@ class HTTPSTest(TestCase):
         h.close()
         # Passing check_hostname to HTTPSConnection should override the
         # context's setting.
-        h = client.HTTPSConnection('localhost', server.port, context=context,
-                                   check_hostname=True)
+        with support.check_warnings(('', DeprecationWarning)):
+            h = client.HTTPSConnection('localhost', server.port,
+                                       context=context, check_hostname=True)
         with self.assertRaises(ssl.CertificateError):
             h.request('GET', '/')