[Python-checkins] r76038 - in python/branches/release26-maint: Lib/test/test_support.py
antoine.pitrou
python-checkins at python.org
Sun Nov 1 23:06:59 CET 2009
Author: antoine.pitrou
Date: Sun Nov 1 23:06:59 2009
New Revision: 76038
Log:
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.
........
Modified:
python/branches/release26-maint/ (props changed)
python/branches/release26-maint/Lib/test/test_support.py
Modified: python/branches/release26-maint/Lib/test/test_support.py
==============================================================================
--- python/branches/release26-maint/Lib/test/test_support.py (original)
+++ python/branches/release26-maint/Lib/test/test_support.py Sun Nov 1 23:06:59 2009
@@ -378,7 +378,7 @@
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 @@
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):
More information about the Python-checkins
mailing list