Issue #21503: Use test_both() consistently in test_importlib.

This commit is contained in:
Eric Snow 2014-05-16 11:40:40 -06:00
parent d50cee2045
commit 3497c0bf95
30 changed files with 526 additions and 428 deletions

View file

@ -235,9 +235,11 @@ def test_unloadable(self):
warnings.simplefilter('ignore', DeprecationWarning)
loader.load_module('bad name')
Frozen_SimpleTest, Source_SimpleTest = util.test_both(
SimpleTest, importlib=importlib, machinery=machinery, abc=importlib_abc,
util=importlib_util)
(Frozen_SimpleTest,
Source_SimpleTest
) = util.test_both(SimpleTest, importlib=importlib, machinery=machinery,
abc=importlib_abc, util=importlib_util)
class BadBytecodeTest:
@ -346,6 +348,7 @@ def _test_bad_magic(self, test, *, del_source=False):
lambda bc: b'\x00\x00\x00\x00' + bc[4:])
test('_temp', mapping, bc_path)
class BadBytecodeTestPEP451(BadBytecodeTest):
def import_(self, file, module_name):
@ -354,6 +357,7 @@ def import_(self, file, module_name):
module.__spec__ = self.util.spec_from_loader(module_name, loader)
loader.exec_module(module)
class BadBytecodeTestPEP302(BadBytecodeTest):
def import_(self, file, module_name):
@ -490,21 +494,29 @@ def test_read_only_bytecode(self):
# Make writable for eventual clean-up.
os.chmod(bytecode_path, stat.S_IWUSR)
class SourceLoaderBadBytecodeTestPEP451(
SourceLoaderBadBytecodeTest, BadBytecodeTestPEP451):
pass
Frozen_SourceBadBytecodePEP451, Source_SourceBadBytecodePEP451 = util.test_both(
SourceLoaderBadBytecodeTestPEP451, importlib=importlib, machinery=machinery,
abc=importlib_abc, util=importlib_util)
(Frozen_SourceBadBytecodePEP451,
Source_SourceBadBytecodePEP451
) = util.test_both(SourceLoaderBadBytecodeTestPEP451, importlib=importlib,
machinery=machinery, abc=importlib_abc,
util=importlib_util)
class SourceLoaderBadBytecodeTestPEP302(
SourceLoaderBadBytecodeTest, BadBytecodeTestPEP302):
pass
Frozen_SourceBadBytecodePEP302, Source_SourceBadBytecodePEP302 = util.test_both(
SourceLoaderBadBytecodeTestPEP302, importlib=importlib, machinery=machinery,
abc=importlib_abc, util=importlib_util)
(Frozen_SourceBadBytecodePEP302,
Source_SourceBadBytecodePEP302
) = util.test_both(SourceLoaderBadBytecodeTestPEP302, importlib=importlib,
machinery=machinery, abc=importlib_abc,
util=importlib_util)
class SourcelessLoaderBadBytecodeTest:
@ -566,21 +578,29 @@ def test_no_marshal(self):
def test_non_code_marshal(self):
self._test_non_code_marshal(del_source=True)
class SourcelessLoaderBadBytecodeTestPEP451(SourcelessLoaderBadBytecodeTest,
BadBytecodeTestPEP451):
pass
Frozen_SourcelessBadBytecodePEP451, Source_SourcelessBadBytecodePEP451 = util.test_both(
SourcelessLoaderBadBytecodeTestPEP451, importlib=importlib,
machinery=machinery, abc=importlib_abc, util=importlib_util)
(Frozen_SourcelessBadBytecodePEP451,
Source_SourcelessBadBytecodePEP451
) = util.test_both(SourcelessLoaderBadBytecodeTestPEP451, importlib=importlib,
machinery=machinery, abc=importlib_abc,
util=importlib_util)
class SourcelessLoaderBadBytecodeTestPEP302(SourcelessLoaderBadBytecodeTest,
BadBytecodeTestPEP302):
pass
Frozen_SourcelessBadBytecodePEP302, Source_SourcelessBadBytecodePEP302 = util.test_both(
SourcelessLoaderBadBytecodeTestPEP302, importlib=importlib,
machinery=machinery, abc=importlib_abc, util=importlib_util)
(Frozen_SourcelessBadBytecodePEP302,
Source_SourcelessBadBytecodePEP302
) = util.test_both(SourcelessLoaderBadBytecodeTestPEP302, importlib=importlib,
machinery=machinery, abc=importlib_abc,
util=importlib_util)
if __name__ == '__main__':