[Python-checkins] r76037 - python/trunk/Lib/test/test_support.py
antoine.pitrou
python-checkins at python.org
Sun Nov 1 23:02:03 CET 2009
Author: antoine.pitrou
Date: Sun Nov 1 23:02:03 2009
New Revision: 76037
Log:
Use a custom timeout in test_support.open_urlresource.
Modified:
python/trunk/Lib/test/test_support.py
Modified: python/trunk/Lib/test/test_support.py
==============================================================================
--- python/trunk/Lib/test/test_support.py (original)
+++ python/trunk/Lib/test/test_support.py Sun Nov 1 23:02:03 2009
@@ -463,7 +463,7 @@
'<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 @@
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)
More information about the Python-checkins
mailing list