[Python-checkins] cpython: Issue 28022: Catch deprecation warning in test_httplib, reported by Martin

christian.heimes python-checkins at python.org
Sun Sep 11 13:54:50 EDT 2016


https://hg.python.org/cpython/rev/2e541e994927
changeset:   103644:2e541e994927
user:        Christian Heimes <christian at python.org>
date:        Sun Sep 11 19:54:43 2016 +0200
summary:
  Issue 28022: Catch deprecation warning in test_httplib, reported by Martin Panter

files:
  Lib/test/test_httplib.py |  15 +++++++++------
  1 files changed, 9 insertions(+), 6 deletions(-)


diff --git a/Lib/test/test_httplib.py b/Lib/test/test_httplib.py
--- a/Lib/test/test_httplib.py
+++ b/Lib/test/test_httplib.py
@@ -1642,14 +1642,16 @@
         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 @@
         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', '/')
 

-- 
Repository URL: https://hg.python.org/cpython


More information about the Python-checkins mailing list