[Python-checkins] cpython (3.4): don't fail tests when www.python.org can't be validated by the system

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


https://hg.python.org/cpython/rev/ca7d00b9d425
changeset:   93590:ca7d00b9d425
branch:      3.4
parent:      93582:f75d40c02f0a
user:        Benjamin Peterson <benjamin at python.org>
date:        Tue Nov 25 15:16:55 2014 -0600
summary:
  don't fail tests when www.python.org can't be validated by the system

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 e.reason == "CERTIFICATE_VERIFY_FAILED":
+                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
@@ -794,6 +794,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