summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_urllib2net.py
diff options
context:
space:
mode:
authorSenthil Kumaran <orsenthil@gmail.com>2010-04-20 07:06:45 (GMT)
committerSenthil Kumaran <orsenthil@gmail.com>2010-04-20 07:06:45 (GMT)
commitc00deec386dcf11ff2b35b51dd7e8ad87ab00d1b (patch)
tree1bdecbc62da549c63326d02e77687d4a1162ad62 /Lib/test/test_urllib2net.py
parent6f76187fb2065be27093c369542f13b1993b2826 (diff)
downloadcpython-c00deec386dcf11ff2b35b51dd7e8ad87ab00d1b.zip
cpython-c00deec386dcf11ff2b35b51dd7e8ad87ab00d1b.tar.gz
cpython-c00deec386dcf11ff2b35b51dd7e8ad87ab00d1b.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.py21
1 files changed, 16 insertions, 5 deletions
diff --git a/Lib/test/test_urllib2net.py b/Lib/test/test_urllib2net.py
index b4e6ae5..162b816 100644
--- a/Lib/test/test_urllib2net.py
+++ b/Lib/test/test_urllib2net.py
@@ -8,7 +8,9 @@ import socket
import urllib2
import sys
import os
-import mimetools
+import sys
+
+TIMEOUT = 60 # seconds
def _retry_thrice(func, exc, *args, **kwargs):
@@ -170,18 +172,27 @@ class OtherNetworkTests(unittest.TestCase):
req = expected_err = None
debug(url)
try:
- f = urlopen(url, req)
+ f = urlopen(url, req, TIMEOUT)
except EnvironmentError, 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.assert_(isinstance(err, expected_err), msg)
+ except urllib2.URLError as err:
+ if isinstance(err[0], socket.timeout):
+ print >>sys.stderr, "<timeout: %s>" % url
+ continue
+ else:
+ raise
else:
- with test_support.transient_internet():
- buf = f.read()
+ try:
+ with test_support.transient_internet():
+ buf = f.read()
+ debug("read %d bytes" % len(buf))
+ except socket.timeout:
+ print >>sys.stderr, "<timeout: %s>" % url
f.close()
- debug("read %d bytes" % len(buf))
debug("******** next url coming up...")
time.sleep(0.1)