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/builtin | |
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/builtin')
-rw-r--r-- | Lib/test/test_importlib/builtin/test_loader.py | 72 |
1 files changed, 0 insertions, 72 deletions
diff --git a/Lib/test/test_importlib/builtin/test_loader.py b/Lib/test/test_importlib/builtin/test_loader.py index 8e12813..a636f77 100644 --- a/Lib/test/test_importlib/builtin/test_loader.py +++ b/Lib/test/test_importlib/builtin/test_loader.py @@ -9,78 +9,6 @@ import types import unittest -class ExecModTests(abc.LoaderTests): - - """Test exec_module() for built-in modules.""" - - @classmethod - def setUpClass(cls): - cls.verification = {'__name__': 'errno', '__package__': '', - '__loader__': cls.machinery.BuiltinImporter} - - def verify(self, module): - """Verify that the module matches against what it should have.""" - self.assertIsInstance(module, types.ModuleType) - for attr, value in self.verification.items(): - self.assertEqual(getattr(module, attr), value) - self.assertIn(module.__name__, sys.modules) - self.assertTrue(hasattr(module, '__spec__')) - self.assertEqual(module.__spec__.origin, 'built-in') - - def load_spec(self, name): - spec = self.machinery.ModuleSpec(name, self.machinery.BuiltinImporter, - origin='built-in') - module = types.ModuleType(name) - module.__spec__ = spec - self.machinery.BuiltinImporter.exec_module(module) - # Strictly not what exec_module() is supposed to do, but since - # _imp.init_builtin() does this we can't get around it. - return sys.modules[name] - - def test_module(self): - # Common case. - with util.uncache(builtin_util.NAME): - module = self.load_spec(builtin_util.NAME) - self.verify(module) - self.assertIn('built-in', str(module)) - - # Built-in modules cannot be a package. - test_package = None - - # Built-in modules cannot be a package. - test_lacking_parent = None - - # Not way to force an import failure. - test_state_after_failure = None - - def test_unloadable(self): - name = 'dssdsdfff' - assert name not in sys.builtin_module_names - with self.assertRaises(ImportError) as cm: - self.load_spec(name) - self.assertEqual(cm.exception.name, name) - - def test_already_imported(self): - # Using the name of a module already imported but not a built-in should - # still fail. - module_name = 'builtin_reload_test' - assert module_name not in sys.builtin_module_names - with util.uncache(module_name): - module = types.ModuleType(module_name) - spec = self.machinery.ModuleSpec(module_name, - self.machinery.BuiltinImporter, - origin='built-in') - module.__spec__ = spec - sys.modules[module_name] = module - with self.assertRaises(ImportError) as cm: - self.machinery.BuiltinImporter.exec_module(module) - self.assertEqual(cm.exception.name, module_name) - - -Frozen_ExecModTests, Source_ExecModTests = util.test_both(ExecModTests, - machinery=[frozen_machinery, source_machinery]) - - class LoaderTests(abc.LoaderTests): """Test load_module() for built-in modules.""" |