Issue #22596: support.transient_internet() now also catches

ConnectionRefusedError exceptions wrapped by urllib.error.URLError.

This change should fix sporadic failures in test_urllib2net.
This commit is contained in:
Berker Peksag 2014-10-25 05:42:30 +03:00
parent 6d1c149a46
commit 8b63d3af9f
2 changed files with 4 additions and 6 deletions

View file

@ -229,6 +229,7 @@ class OtherNetworkTests(unittest.TestCase):
with support.transient_internet(url):
try:
f = urlopen(url, req, TIMEOUT)
# urllib.error.URLError is a subclass of OSError
except OSError as err:
if expected_err:
msg = ("Didn't get expected error(s) %s for %s %s, got %s: %s" %
@ -236,12 +237,6 @@ class OtherNetworkTests(unittest.TestCase):
self.assertIsInstance(err, expected_err, msg)
else:
raise
except urllib.error.URLError as err:
if isinstance(err[0], socket.timeout):
print("<timeout: %s>" % url, file=sys.stderr)
continue
else:
raise
else:
try:
with support.time_out, \