summaryrefslogtreecommitdiff
path: root/Lib/test/test_support.py
diff options
context:
space:
mode:
authorHye-Shik Chang <hyeshik@gmail.com>2005-12-10 17:44:27 +0000
committerHye-Shik Chang <hyeshik@gmail.com>2005-12-10 17:44:27 +0000
commit3a5583fa4df80c52c72475dbb2254b5da50ca4a4 (patch)
treea98267568ca588ac27df1d54b5e32bb7265e1c47 /Lib/test/test_support.py
parent44b95154c769b005c3d87224887d1b66d5b9ee81 (diff)
downloadcpython-3a5583fa4df80c52c72475dbb2254b5da50ca4a4.tar.gz
Patch #1276356: Implement new resource "urlfetch" for regrtest.
This enables even impatient people to run tests that require remote files such as test_normalization and test_codecmaps_*.
Diffstat (limited to 'Lib/test/test_support.py')
-rw-r--r--Lib/test/test_support.py14
1 files changed, 14 insertions, 0 deletions
diff --git a/Lib/test/test_support.py b/Lib/test/test_support.py
index a296caf6d0..bec1a0f401 100644
--- a/Lib/test/test_support.py
+++ b/Lib/test/test_support.py
@@ -237,7 +237,21 @@ def check_syntax(statement):
else:
print 'Missing SyntaxError: "%s"' % statement
+def open_urlresource(url):
+ import urllib, urlparse
+ import os.path
+ filename = urlparse.urlparse(url)[2].split('/')[-1] # '/': it's URL!
+
+ for path in [os.path.curdir, os.path.pardir]:
+ fn = os.path.join(path, filename)
+ if os.path.exists(fn):
+ return open(fn)
+
+ requires('urlfetch')
+ print >> get_original_stdout(), '\tfetching %s ...' % url
+ fn, _ = urllib.urlretrieve(url, filename)
+ return open(fn)
#=======================================================================
# Preliminary PyUNIT integration.