summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAntoine Pitrou <solipsis@pitrou.net>2009-11-01 22:06:59 (GMT)
committerAntoine Pitrou <solipsis@pitrou.net>2009-11-01 22:06:59 (GMT)
commit07728e9b46cdde12b8f16582916b14a89446e275 (patch)
tree21b6dd344cfe9353cac856dcdf3c67b00f8e924d
parent1ccb66a5bd7360f9c7f123f6828a27aa244fd489 (diff)
downloadcpython-07728e9b46cdde12b8f16582916b14a89446e275.zip
cpython-07728e9b46cdde12b8f16582916b14a89446e275.tar.gz
cpython-07728e9b46cdde12b8f16582916b14a89446e275.tar.bz2
Merged revisions 76037 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk ........ r76037 | antoine.pitrou | 2009-11-01 23:02:03 +0100 (dim., 01 nov. 2009) | 3 lines Use a custom timeout in test_support.open_urlresource. ........
-rw-r--r--Lib/test/test_support.py14
1 files changed, 11 insertions, 3 deletions
diff --git a/Lib/test/test_support.py b/Lib/test/test_support.py
index c9fb092..d4b891e 100644
--- a/Lib/test/test_support.py
+++ b/Lib/test/test_support.py
@@ -378,7 +378,7 @@ def check_syntax_error(testcase, statement):
testcase.fail('Missing SyntaxError: "%s"' % statement)
def open_urlresource(url):
- import urllib, urlparse
+ import urlparse, urllib2
requires('urlfetch')
filename = urlparse.urlparse(url)[2].split('/')[-1] # '/': it's URL!
@@ -389,8 +389,16 @@ def open_urlresource(url):
return open(fn)
print >> get_original_stdout(), '\tfetching %s ...' % url
- fn, _ = urllib.urlretrieve(url, filename)
- return open(fn)
+ f = urllib2.urlopen(url, timeout=15)
+ try:
+ with open(filename, "wb") as out:
+ s = f.read()
+ while s:
+ out.write(s)
+ s = f.read()
+ finally:
+ f.close()
+ return open(filename)
class WarningsRecorder(object):