diff options
author | Eric Snow <ericsnowcurrently@gmail.com> | 2013-08-15 00:11:09 (GMT) |
---|---|---|
committer | Eric Snow <ericsnowcurrently@gmail.com> | 2013-08-15 00:11:09 (GMT) |
commit | 8e4554027b8ba1e6fc3b9e1a67d3333a3399a6d6 (patch) | |
tree | 7b33f885875ae3fe783d6599e1010cfaefc0ad27 /Lib/test | |
parent | 01dbca0b0626c7846d917883e6b7b5667c4fe6ba (diff) | |
download | cpython-8e4554027b8ba1e6fc3b9e1a67d3333a3399a6d6.zip cpython-8e4554027b8ba1e6fc3b9e1a67d3333a3399a6d6.tar.gz cpython-8e4554027b8ba1e6fc3b9e1a67d3333a3399a6d6.tar.bz2 |
Closes issue #18698: ensure importlib.reload() returns the module out of sys.modules.
Diffstat (limited to 'Lib/test')
-rw-r--r-- | Lib/test/test_importlib/test_api.py | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/Lib/test/test_importlib/test_api.py b/Lib/test/test_importlib/test_api.py index 3a28cb7..0c0e851 100644 --- a/Lib/test/test_importlib/test_api.py +++ b/Lib/test/test_importlib/test_api.py @@ -162,6 +162,22 @@ class ReloadTests(unittest.TestCase): module = importlib.import_module(mod) importlib.reload(module) + def test_module_replaced(self): + def code(): + import sys + module = type(sys)('top_level') + module.spam = 3 + sys.modules['top_level'] = module + mock = util.mock_modules('top_level', + module_code={'top_level': code}) + with mock: + with util.import_state(meta_path=[mock]): + module = importlib.import_module('top_level') + reloaded = importlib.reload(module) + actual = sys.modules['top_level'] + self.assertEqual(actual.spam, 3) + self.assertEqual(reloaded.spam, 3) + class InvalidateCacheTests(unittest.TestCase): |