diff options
author | Brett Cannon <brett@python.org> | 2013-11-29 16:00:11 (GMT) |
---|---|---|
committer | Brett Cannon <brett@python.org> | 2013-11-29 16:00:11 (GMT) |
commit | d2476c6e4bfa0666343643277e54f8d89015cded (patch) | |
tree | 9dbc0abe44bc8f8be91d682580b51e250c091dfe /Lib/test/test_importlib/extension | |
parent | 0e90e99188d6fb54c3f5b31a0488318d9c38309d (diff) | |
download | cpython-d2476c6e4bfa0666343643277e54f8d89015cded.zip cpython-d2476c6e4bfa0666343643277e54f8d89015cded.tar.gz cpython-d2476c6e4bfa0666343643277e54f8d89015cded.tar.bz2 |
Issue #19698: Remove exec_module() from the built-in and extension
module loaders.
Due to the fact that the call signatures for extension modules and
built-in modules does not allow for the specifying of what module to
initialize and that on Windows all extension modules are built-in
modules, work to clean up built-in and extension module initialization
will have to wait until Python 3.5. Because of this the semantics of
exec_module() would be incorrect, so removing the methods for now is
the best option; load_module() is still used as a fallback by
importlib and so this won't affect semantics.
Diffstat (limited to 'Lib/test/test_importlib/extension')
-rw-r--r-- | Lib/test/test_importlib/extension/test_loader.py | 65 |
1 files changed, 0 insertions, 65 deletions
diff --git a/Lib/test/test_importlib/extension/test_loader.py b/Lib/test/test_importlib/extension/test_loader.py index 58bd09f..d04dff5 100644 --- a/Lib/test/test_importlib/extension/test_loader.py +++ b/Lib/test/test_importlib/extension/test_loader.py @@ -10,71 +10,6 @@ import types import unittest -class ExecModuleTests(abc.LoaderTests): - - """Test load_module() for extension modules.""" - - def setUp(self): - self.loader = self.machinery.ExtensionFileLoader(ext_util.NAME, - ext_util.FILEPATH) - - def exec_module(self, fullname): - module = types.ModuleType(fullname) - module.__spec__ = self.machinery.ModuleSpec(fullname, self.loader) - self.loader.exec_module(module) - return sys.modules[fullname] - - def test_exec_module_API(self): - with self.assertRaises(ImportError): - self.exec_module('XXX') - - - def test_module(self): - with util.uncache(ext_util.NAME): - module = self.exec_module(ext_util.NAME) - for attr, value in [('__name__', ext_util.NAME), - ('__file__', ext_util.FILEPATH), - ('__package__', '')]: - given = getattr(module, attr) - self.assertEqual(given, value, - '{}: {!r} != {!r}'.format(attr, given, value)) - self.assertIn(ext_util.NAME, sys.modules) - self.assertIsInstance(module.__loader__, - self.machinery.ExtensionFileLoader) - - # No extension module as __init__ available for testing. - test_package = None - - # No extension module in a package available for testing. - test_lacking_parent = None - - def test_module_reuse(self): - with util.uncache(ext_util.NAME): - module1 = self.exec_module(ext_util.NAME) - module2 = self.exec_module(ext_util.NAME) - self.assertIs(module1, module2) - - def test_state_after_failure(self): - # No easy way to trigger a failure after a successful import. - pass - - def test_unloadable(self): - name = 'asdfjkl;' - with self.assertRaises(ImportError) as cm: - self.exec_module(name) - self.assertEqual(cm.exception.name, name) - - def test_is_package(self): - self.assertFalse(self.loader.is_package(ext_util.NAME)) - for suffix in self.machinery.EXTENSION_SUFFIXES: - path = os.path.join('some', 'path', 'pkg', '__init__' + suffix) - loader = self.machinery.ExtensionFileLoader('pkg', path) - self.assertTrue(loader.is_package('pkg')) - -Frozen_ExecModuleTests, Source_ExecModuleTests = util.test_both( - ExecModuleTests, machinery=machinery) - - class LoaderTests(abc.LoaderTests): """Test load_module() for extension modules.""" |