diff options
author | Eric Snow <ericsnowcurrently@gmail.com> | 2013-11-22 09:05:39 -0700 |
---|---|---|
committer | Eric Snow <ericsnowcurrently@gmail.com> | 2013-11-22 09:05:39 -0700 |
commit | b523f8433a8982e10eb41a3e2b37ee0e6d6a6e00 (patch) | |
tree | b38661db4903b7edc4042e7562b32720dd3687bf /Lib/test/test_importlib/test_util.py | |
parent | 9e6097ebe7bb99a4a22b949ef4b1563b21ad7166 (diff) | |
download | cpython-b523f8433a8982e10eb41a3e2b37ee0e6d6a6e00.tar.gz cpython-b523f8433a8982e10eb41a3e2b37ee0e6d6a6e00.zip |
Implement PEP 451 (ModuleSpec).
Diffstat (limited to 'Lib/test/test_importlib/test_util.py')
-rw-r--r-- | Lib/test/test_importlib/test_util.py | 65 |
1 files changed, 0 insertions, 65 deletions
diff --git a/Lib/test/test_importlib/test_util.py b/Lib/test/test_importlib/test_util.py index 2ac57df3ac4..604e44d1b35 100644 --- a/Lib/test/test_importlib/test_util.py +++ b/Lib/test/test_importlib/test_util.py @@ -34,71 +34,6 @@ Frozen_DecodeSourceBytesTests, Source_DecodeSourceBytesTests = test_util.test_bo DecodeSourceBytesTests, util=[frozen_util, source_util]) -class ModuleToLoadTests: - - module_name = 'ModuleManagerTest_module' - - def setUp(self): - support.unload(self.module_name) - self.addCleanup(support.unload, self.module_name) - - def test_new_module(self): - # Test a new module is created, inserted into sys.modules, has - # __initializing__ set to True after entering the context manager, - # and __initializing__ set to False after exiting. - with self.util.module_to_load(self.module_name) as module: - self.assertIn(self.module_name, sys.modules) - self.assertIs(sys.modules[self.module_name], module) - self.assertTrue(module.__initializing__) - self.assertFalse(module.__initializing__) - - def test_new_module_failed(self): - # Test the module is removed from sys.modules. - try: - with self.util.module_to_load(self.module_name) as module: - self.assertIn(self.module_name, sys.modules) - raise exception - except Exception: - self.assertNotIn(self.module_name, sys.modules) - else: - self.fail('importlib.util.module_to_load swallowed an exception') - - def test_reload(self): - # Test that the same module is in sys.modules. - created_module = types.ModuleType(self.module_name) - sys.modules[self.module_name] = created_module - with self.util.module_to_load(self.module_name) as module: - self.assertIs(module, created_module) - - def test_reload_failed(self): - # Test that the module was left in sys.modules. - created_module = types.ModuleType(self.module_name) - sys.modules[self.module_name] = created_module - try: - with self.util.module_to_load(self.module_name) as module: - raise Exception - except Exception: - self.assertIn(self.module_name, sys.modules) - else: - self.fail('importlib.util.module_to_load swallowed an exception') - - def test_reset_name(self): - # If reset_name is true then module.__name__ = name, else leave it be. - odd_name = 'not your typical name' - created_module = types.ModuleType(self.module_name) - created_module.__name__ = odd_name - sys.modules[self.module_name] = created_module - with self.util.module_to_load(self.module_name) as module: - self.assertEqual(module.__name__, self.module_name) - created_module.__name__ = odd_name - with self.util.module_to_load(self.module_name, reset_name=False) as module: - self.assertEqual(module.__name__, odd_name) - -Frozen_ModuleToLoadTests, Source_ModuleToLoadTests = test_util.test_both( - ModuleToLoadTests, - util=[frozen_util, source_util]) - - class ModuleForLoaderTests: """Tests for importlib.util.module_for_loader.""" |