diff options
author | Antoine Pitrou <solipsis@pitrou.net> | 2009-11-01 22:28:14 (GMT) |
---|---|---|
committer | Antoine Pitrou <solipsis@pitrou.net> | 2009-11-01 22:28:14 (GMT) |
commit | ec416617e8677d3f8ab9555b4a682f1ed1cc0f72 (patch) | |
tree | 629cc5ae6abdaa46397161f22809010d8745d815 /Lib/test | |
parent | 2fe253436ae345387e9aaf9f8354a404b1a850e4 (diff) | |
download | cpython-ec416617e8677d3f8ab9555b4a682f1ed1cc0f72.zip cpython-ec416617e8677d3f8ab9555b4a682f1ed1cc0f72.tar.gz cpython-ec416617e8677d3f8ab9555b4a682f1ed1cc0f72.tar.bz2 |
Merged revisions 76040 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/branches/py3k
................
r76040 | antoine.pitrou | 2009-11-01 23:13:48 +0100 (dim., 01 nov. 2009) | 9 lines
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.
........
................
Diffstat (limited to 'Lib/test')
-rw-r--r-- | Lib/test/support.py | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/Lib/test/support.py b/Lib/test/support.py index 5b4cc5b..5672a20 100644 --- a/Lib/test/support.py +++ b/Lib/test/support.py @@ -455,9 +455,16 @@ def open_urlresource(url, *args, **kw): return open(fn, *args, **kw) print('\tfetching %s ...' % url, file=get_original_stdout()) - fn, _ = urllib.request.urlretrieve(url, filename) - return open(fn, *args, **kw) - + f = urllib.request.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, *args, **kw) class WarningsRecorder(object): """Convenience wrapper for the warnings list returned on |