diff options
author | Senthil Kumaran <orsenthil@gmail.com> | 2010-04-20 10:35:49 (GMT) |
---|---|---|
committer | Senthil Kumaran <orsenthil@gmail.com> | 2010-04-20 10:35:49 (GMT) |
commit | b8f7ea6ceb52c2f51f349ba1b761988b2cbc3ece (patch) | |
tree | 6cd90196fce38a49bf6d28efa5fbc73cd94d9bd5 /Lib/test/test_urllib2net.py | |
parent | 11d22dce3af2f21337f51f285512865833f8f259 (diff) | |
download | cpython-b8f7ea6ceb52c2f51f349ba1b761988b2cbc3ece.zip cpython-b8f7ea6ceb52c2f51f349ba1b761988b2cbc3ece.tar.gz cpython-b8f7ea6ceb52c2f51f349ba1b761988b2cbc3ece.tar.bz2 |
Merged revisions 80236 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r80236 | senthil.kumaran | 2010-04-20 12:24:59 +0530 (Tue, 20 Apr 2010) | 3 lines
Fix Issue8460: Victor's patch to add timeout in test_urllib2net test_urls.
........
Diffstat (limited to 'Lib/test/test_urllib2net.py')
-rw-r--r-- | Lib/test/test_urllib2net.py | 24 |
1 files changed, 18 insertions, 6 deletions
diff --git a/Lib/test/test_urllib2net.py b/Lib/test/test_urllib2net.py index 1dea93f..ff7c7bf 100644 --- a/Lib/test/test_urllib2net.py +++ b/Lib/test/test_urllib2net.py @@ -8,6 +8,9 @@ import os import socket import urllib.error import urllib.request +import sys + +TIMEOUT = 60 # seconds def _retry_thrice(func, exc, *args, **kwargs): @@ -162,20 +165,29 @@ class OtherNetworkTests(unittest.TestCase): req = expected_err = None debug(url) try: - f = urlopen(url, req) + f = urlopen(url, req, TIMEOUT) except EnvironmentError as err: debug(err) if expected_err: msg = ("Didn't get expected error(s) %s for %s %s, got %s: %s" % (expected_err, url, req, type(err), err)) self.assertIsInstance(err, expected_err, msg) + except urllib.error.URLError as err: + if isinstance(err[0], socket.timeout): + print("<timeout: %s>" % url, file=sys.stderr) + continue + else: + raise else: - with support.time_out, \ - support.socket_peer_reset, \ - support.ioerror_peer_reset: - buf = f.read() + try: + with support.time_out, \ + support.socket_peer_reset, \ + support.ioerror_peer_reset: + buf = f.read() + debug("read %d bytes" % len(buf)) + except socket.timeout: + print("<timeout: %s>" % url, file=sys.stderr) f.close() - debug("read %d bytes" % len(buf)) debug("******** next url coming up...") time.sleep(0.1) |