]> granicus.if.org Git - python/commitdiff
Issue 26798: fetch OSError and HTTPException like other tests that use open_urlresource.
authorChristian Heimes <christian@python.org>
Thu, 8 Sep 2016 08:53:40 +0000 (10:53 +0200)
committerChristian Heimes <christian@python.org>
Thu, 8 Sep 2016 08:53:40 +0000 (10:53 +0200)
Lib/test/test_hashlib.py

index 21260f6ea6374e477c3758f9eef0d55ca8528909..5ae8c070375cb717e3ff7508f20f391e21ef0e47 100644 (file)
@@ -20,6 +20,7 @@ import unittest
 import warnings
 from test import support
 from test.support import _4G, bigmemtest, import_fresh_module
+from http.client import HTTPException
 
 # Were we compiled --with-pydebug or with #define Py_DEBUG?
 COMPILED_WITH_PYDEBUG = hasattr(sys, 'gettotalrefcount')
@@ -54,8 +55,13 @@ def hexstr(s):
 URL = "http://www.pythontest.net/hashlib/{}.txt"
 
 def read_vectors(hash_name):
-    with support.open_urlresource(URL.format(hash_name)) as f:
-        for line in f:
+    url = URL.format(hash_name)
+    try:
+        testdata = support.open_urlresource(url)
+    except (OSError, HTTPException):
+        raise unittest.SkipTest("Could not retrieve {}".format(url))
+    with testdata:
+        for line in testdata:
             line = line.strip()
             if line.startswith('#') or not line:
                 continue