]> granicus.if.org Git - python/commitdiff
don't fail tests when www.python.org can't be validated by the system
authorBenjamin Peterson <benjamin@python.org>
Tue, 25 Nov 2014 21:16:55 +0000 (15:16 -0600)
committerBenjamin Peterson <benjamin@python.org>
Tue, 25 Nov 2014 21:16:55 +0000 (15:16 -0600)
Lib/test/support/__init__.py
Lib/test/test_httplib.py

index e6db70ff5c78a06bd94385a5af8710fcbf054955..253f319c1363f669688bdfb2974be479025ca72d 100644 (file)
@@ -691,6 +691,18 @@ def _is_ipv6_enabled():
 
 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.
index d259fb28533ac6bfee1bb0ce48a853485444a685..3b57d09e57b639f2a04c4b24e5dfb925683e2024 100644 (file)
@@ -794,6 +794,7 @@ class HTTPSTest(TestCase):
             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')