mirror of
https://github.com/python/cpython.git
synced 2025-08-30 21:48:47 +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
|
@ -163,15 +163,16 @@ class TestBase_Mapping(unittest.TestCase):
|
|||
|
||||
def __init__(self, *args, **kw):
|
||||
unittest.TestCase.__init__(self, *args, **kw)
|
||||
if not os.path.exists(self.mapfilename):
|
||||
raise test_support.TestSkipped('%s not found, download from %s' %
|
||||
(self.mapfilename, self.mapfileurl))
|
||||
self.open_mapping_file() # test it to report the error early
|
||||
|
||||
def open_mapping_file(self):
|
||||
return test_support.open_urlresource(self.mapfileurl)
|
||||
|
||||
def test_mapping_file(self):
|
||||
unichrs = lambda s: u''.join(map(unichr, map(eval, s.split('+'))))
|
||||
urt_wa = {}
|
||||
|
||||
for line in open(self.mapfilename):
|
||||
for line in self.open_mapping_file():
|
||||
if not line:
|
||||
break
|
||||
data = line.split('#')[0].strip().split()
|
||||
|
@ -217,16 +218,3 @@ def load_teststring(encoding):
|
|||
else:
|
||||
from test import cjkencodings_test
|
||||
return cjkencodings_test.teststring[encoding]
|
||||
|
||||
def register_skip_expected(*cases):
|
||||
for case in cases: # len(cases) must be 1 at least.
|
||||
for path in [os.path.curdir, os.path.pardir]:
|
||||
fn = os.path.join(path, case.mapfilename)
|
||||
if os.path.exists(fn):
|
||||
case.mapfilename = fn
|
||||
break
|
||||
else:
|
||||
sys.modules[case.__module__].skip_expected = True
|
||||
break
|
||||
else:
|
||||
sys.modules[case.__module__].skip_expected = False
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue