summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_support.py
diff options
context:
space:
mode:
authorHye-Shik Chang <hyeshik@gmail.com>2005-12-10 17:44:27 (GMT)
committerHye-Shik Chang <hyeshik@gmail.com>2005-12-10 17:44:27 (GMT)
commitaaa2f1dea706daf2a5f431d97a3e3120dba652d2 (patch)
treec602cfc7ed52919ab7cffa175abfe4a6880869ac /Lib/test/test_support.py
parent432be36056ca12f5265616f07d2f369d5878982d (diff)
downloadcpython-aaa2f1dea706daf2a5f431d97a3e3120dba652d2.zip
cpython-aaa2f1dea706daf2a5f431d97a3e3120dba652d2.tar.gz
cpython-aaa2f1dea706daf2a5f431d97a3e3120dba652d2.tar.bz2
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 a296caf..bec1a0f 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.