Skip to content

Commit 8118824

Browse files
committed
Issue 26798: fetch OSError and HTTPException like other tests that use open_urlresource.
1 parent d9fc792 commit 8118824

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

Lib/test/test_hashlib.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
import warnings
2121
from test import support
2222
from test.support import _4G, bigmemtest, import_fresh_module
23+
from http.client import HTTPException
2324

2425
# Were we compiled --with-pydebug or with #define Py_DEBUG?
2526
COMPILED_WITH_PYDEBUG = hasattr(sys, 'gettotalrefcount')
@@ -54,8 +55,13 @@ def hexstr(s):
5455
URL = "http://www.pythontest.net/hashlib/{}.txt"
5556

5657
def read_vectors(hash_name):
57-
with support.open_urlresource(URL.format(hash_name)) as f:
58-
for line in f:
58+
url = URL.format(hash_name)
59+
try:
60+
testdata = support.open_urlresource(url)
61+
except (OSError, HTTPException):
62+
raise unittest.SkipTest("Could not retrieve {}".format(url))
63+
with testdata:
64+
for line in testdata:
5965
line = line.strip()
6066
if line.startswith('#') or not line:
6167
continue

0 commit comments

Comments
 (0)