[Python-checkins] cpython (merge 3.4 -> default): merge 3.4

benjamin.peterson python-checkins at python.org
Wed Nov 26 01:06:07 CET 2014


https://hg.python.org/cpython/rev/81b5268efff6
changeset:   93592:81b5268efff6
parent:      93584:b6fab008d63a
parent:      93591:e635c3ba75c8
user:        Benjamin Peterson <benjamin at python.org>
date:        Tue Nov 25 18:05:40 2014 -0600
summary:
  merge 3.4

files:
  Lib/test/support/__init__.py |  12 ++++++++++++
  Lib/test/test_httplib.py     |   1 +
  2 files changed, 13 insertions(+), 0 deletions(-)


diff --git a/Lib/test/support/__init__.py b/Lib/test/support/__init__.py
--- a/Lib/test/support/__init__.py
+++ b/Lib/test/support/__init__.py
@@ -691,6 +691,18 @@
 
 IPV6_ENABLED = _is_ipv6_enabled()
 
+def system_must_validate_cert(f):
+    """Skip the test on TLS certificate validation failures."""
+    @functools.wraps(f)
+    def dec(*args, **kwargs):
+        try:
+            f(*args, **kwargs)
+        except IOError as e:
+            if "CERTIFICATE_VERIFY_FAILED" in str(e):
+                raise unittest.SkipTest("system does not contain "
+                                        "necessary certificates")
+            raise
+    return dec
 
 # A constant likely larger than the underlying OS pipe buffer size, to
 # make writes blocking.
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
@@ -1028,6 +1028,7 @@
             resp = h.getresponse()
             self.assertIn('nginx', resp.getheader('server'))
 
+    @support.system_must_validate_cert
     def test_networked_trusted_by_default_cert(self):
         # Default settings: requires a valid cert from a trusted CA
         support.requires('network')

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


More information about the Python-checkins mailing list