diff options
author | Brett Cannon <bcannon@gmail.com> | 2009-02-21 05:41:15 (GMT) |
---|---|---|
committer | Brett Cannon <bcannon@gmail.com> | 2009-02-21 05:41:15 (GMT) |
commit | 91cf882b367644ece7f121cd22fc43c2f439a2d5 (patch) | |
tree | 29ed464e53b9c2aa142077091f71e8c2c96d8665 /Lib/importlib/test | |
parent | 0515619dbc0c11818fa15785e40491cf8d01042f (diff) | |
download | cpython-91cf882b367644ece7f121cd22fc43c2f439a2d5.zip cpython-91cf882b367644ece7f121cd22fc43c2f439a2d5.tar.gz cpython-91cf882b367644ece7f121cd22fc43c2f439a2d5.tar.bz2 |
Refactor source and bytecode file loaders in importlib so that there
are source-only and source/bytecode loaders.
Diffstat (limited to 'Lib/importlib/test')
-rw-r--r-- | Lib/importlib/test/source/test_loader.py | 22 | ||||
-rw-r--r-- | Lib/importlib/test/source/test_source_encoding.py | 4 |
2 files changed, 13 insertions, 13 deletions
diff --git a/Lib/importlib/test/source/test_loader.py b/Lib/importlib/test/source/test_loader.py index 4ca9af1..960210f 100644 --- a/Lib/importlib/test/source/test_loader.py +++ b/Lib/importlib/test/source/test_loader.py @@ -19,7 +19,7 @@ class SimpleTest(unittest.TestCase): # [basic] def test_module(self): with source_util.create_modules('_temp') as mapping: - loader = importlib._PyFileLoader('_temp', mapping['_temp'], False) + loader = importlib.PyPycFileLoader('_temp', mapping['_temp'], False) module = loader.load_module('_temp') self.assert_('_temp' in sys.modules) check = {'__name__': '_temp', '__file__': mapping['_temp'], @@ -29,7 +29,7 @@ class SimpleTest(unittest.TestCase): def test_package(self): with source_util.create_modules('_pkg.__init__') as mapping: - loader = importlib._PyFileLoader('_pkg', mapping['_pkg.__init__'], + loader = importlib.PyPycFileLoader('_pkg', mapping['_pkg.__init__'], True) module = loader.load_module('_pkg') self.assert_('_pkg' in sys.modules) @@ -42,7 +42,7 @@ class SimpleTest(unittest.TestCase): def test_lacking_parent(self): with source_util.create_modules('_pkg.__init__', '_pkg.mod')as mapping: - loader = importlib._PyFileLoader('_pkg.mod', mapping['_pkg.mod'], + loader = importlib.PyPycFileLoader('_pkg.mod', mapping['_pkg.mod'], False) module = loader.load_module('_pkg.mod') self.assert_('_pkg.mod' in sys.modules) @@ -57,7 +57,7 @@ class SimpleTest(unittest.TestCase): def test_module_reuse(self): with source_util.create_modules('_temp') as mapping: - loader = importlib._PyFileLoader('_temp', mapping['_temp'], False) + loader = importlib.PyPycFileLoader('_temp', mapping['_temp'], False) module = loader.load_module('_temp') module_id = id(module) module_dict_id = id(module.__dict__) @@ -87,7 +87,7 @@ class SimpleTest(unittest.TestCase): setattr(orig_module, attr, value) with open(mapping[name], 'w') as file: file.write('+++ bad syntax +++') - loader = importlib._PyFileLoader('_temp', mapping['_temp'], False) + loader = importlib.PyPycFileLoader('_temp', mapping['_temp'], False) self.assertRaises(SyntaxError, loader.load_module, name) for attr in attributes: self.assertEqual(getattr(orig_module, attr), value) @@ -97,7 +97,7 @@ class SimpleTest(unittest.TestCase): with source_util.create_modules('_temp') as mapping: with open(mapping['_temp'], 'w') as file: file.write('=') - loader = importlib._PyFileLoader('_temp', mapping['_temp'], False) + loader = importlib.PyPycFileLoader('_temp', mapping['_temp'], False) self.assertRaises(SyntaxError, loader.load_module, '_temp') self.assert_('_temp' not in sys.modules) @@ -112,7 +112,7 @@ class DontWriteBytecodeTest(unittest.TestCase): @source_util.writes_bytecode def run_test(self, assertion): with source_util.create_modules('_temp') as mapping: - loader = importlib._PyFileLoader('_temp', mapping['_temp'], False) + loader = importlib.PyPycFileLoader('_temp', mapping['_temp'], False) loader.load_module('_temp') bytecode_path = source_util.bytecode_path(mapping['_temp']) assertion(bytecode_path) @@ -144,7 +144,7 @@ class BadDataTest(unittest.TestCase): with open(bytecode_path, 'r+b') as file: file.seek(0) file.write(b'\x00\x00\x00\x00') - loader = importlib._PyFileLoader('_temp', mapping['_temp'], False) + loader = importlib.PyPycFileLoader('_temp', mapping['_temp'], False) self.assertRaises(ImportError, loader.load_module, '_temp') self.assert_('_temp' not in sys.modules) @@ -159,7 +159,7 @@ class SourceBytecodeInteraction(unittest.TestCase): """ def import_(self, file, module, *, pkg=False): - loader = importlib._PyFileLoader(module, file, pkg) + loader = importlib.PyPycFileLoader(module, file, pkg) return loader.load_module(module) def run_test(self, test, *create, pkg=False): @@ -171,7 +171,7 @@ class SourceBytecodeInteraction(unittest.TestCase): import_name = test.rsplit('.', 1)[0] else: import_name = test - loader = importlib._PyFileLoader(import_name, mapping[test], pkg) + loader = importlib.PyPycFileLoader(import_name, mapping[test], pkg) # Because some platforms only have a granularity to the second for # atime you can't check the physical files. Instead just make it an # exception trigger if source was read. @@ -212,7 +212,7 @@ class BadBytecodeTest(unittest.TestCase): """ def import_(self, file, module_name): - loader = importlib._PyFileLoader(module_name, file, False) + loader = importlib.PyPycFileLoader(module_name, file, False) module = loader.load_module(module_name) self.assert_(module_name in sys.modules) diff --git a/Lib/importlib/test/source/test_source_encoding.py b/Lib/importlib/test/source/test_source_encoding.py index 5ffdf8f..9e9c7e8 100644 --- a/Lib/importlib/test/source/test_source_encoding.py +++ b/Lib/importlib/test/source/test_source_encoding.py @@ -35,7 +35,7 @@ class EncodingTest(unittest.TestCase): with source_util.create_modules(self.module_name) as mapping: with open(mapping[self.module_name], 'wb')as file: file.write(source) - loader = importlib._PyFileLoader(self.module_name, + loader = importlib.PyPycFileLoader(self.module_name, mapping[self.module_name], False) return loader.load_module(self.module_name) @@ -96,7 +96,7 @@ class LineEndingTest(unittest.TestCase): with source_util.create_modules(module_name) as mapping: with open(mapping[module_name], 'wb') as file: file.write(source) - loader = importlib._PyFileLoader(module_name, mapping[module_name], + loader = importlib.PyPycFileLoader(module_name, mapping[module_name], False) return loader.load_module(module_name) |