diff options
author | Antoine Pitrou <solipsis@pitrou.net> | 2009-11-01 22:02:03 (GMT) |
---|---|---|
committer | Antoine Pitrou <solipsis@pitrou.net> | 2009-11-01 22:02:03 (GMT) |
commit | 84ee9e257ea508284c29effa4253226502b38428 (patch) | |
tree | f465368e35e16c5663af4107561c2e6e56f57dba /Lib/test | |
parent | e4c6b16b37937ccf9335a8b2a51adfd4ad0d7e7b (diff) | |
download | cpython-84ee9e257ea508284c29effa4253226502b38428.zip cpython-84ee9e257ea508284c29effa4253226502b38428.tar.gz cpython-84ee9e257ea508284c29effa4253226502b38428.tar.bz2 |
Use a custom timeout in test_support.open_urlresource.
Diffstat (limited to 'Lib/test')
-rw-r--r-- | Lib/test/test_support.py | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/Lib/test/test_support.py b/Lib/test/test_support.py index fa46be2..c2dcb57 100644 --- a/Lib/test/test_support.py +++ b/Lib/test/test_support.py @@ -463,7 +463,7 @@ def check_syntax_error(testcase, statement): '<test string>', 'exec') def open_urlresource(url): - import urllib, urlparse + import urlparse, urllib2 requires('urlfetch') filename = urlparse.urlparse(url)[2].split('/')[-1] # '/': it's URL! @@ -473,7 +473,15 @@ def open_urlresource(url): return open(fn) print >> get_original_stdout(), '\tfetching %s ...' % url - fn, _ = urllib.urlretrieve(url, fn) + f = urllib2.urlopen(url, timeout=15) + try: + with open(fn, "wb") as out: + s = f.read() + while s: + out.write(s) + s = f.read() + finally: + f.close() return open(fn) |