[Python-checkins] cpython: Issue 26798: fetch OSError and HTTPException like other tests that use

christian.heimes python-checkins at python.org
Thu Sep 8 05:07:21 EDT 2016


https://hg.python.org/cpython/rev/46b34706eb41
changeset:   103300:46b34706eb41
user:        Christian Heimes <christian at python.org>
date:        Thu Sep 08 10:53:40 2016 +0200
summary:
  Issue 26798: fetch OSError and HTTPException like other tests that use open_urlresource.

files:
  Lib/test/test_hashlib.py |  10 ++++++++--
  1 files changed, 8 insertions(+), 2 deletions(-)


diff --git a/Lib/test/test_hashlib.py b/Lib/test/test_hashlib.py
--- a/Lib/test/test_hashlib.py
+++ b/Lib/test/test_hashlib.py
@@ -20,6 +20,7 @@
 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 @@
 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

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


More information about the Python-checkins mailing list