mirror of
https://github.com/python/cpython.git
synced 2025-08-30 13:38:43 +00:00
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_*.
This commit is contained in:
parent
432be36056
commit
aaa2f1dea7
10 changed files with 29 additions and 74 deletions
|
@ -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.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue