summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_importlib/import_
diff options
context:
space:
mode:
authorBarry Warsaw <barry@python.org>2012-11-20 22:10:10 (GMT)
committerBarry Warsaw <barry@python.org>2012-11-20 22:10:10 (GMT)
commited843b5e5c7e222a54d89aaadb0a8342d06140a3 (patch)
tree6ede6dcac753bf5bc7fe05fb8016461c1ccd8c25 /Lib/test/test_importlib/import_
parenta34412a992e5d375a37499c36957448f6b1059ba (diff)
downloadcpython-ed843b5e5c7e222a54d89aaadb0a8342d06140a3.zip
cpython-ed843b5e5c7e222a54d89aaadb0a8342d06140a3.tar.gz
cpython-ed843b5e5c7e222a54d89aaadb0a8342d06140a3.tar.bz2
Do a better job of preserving the state of sys.modules.
Diffstat (limited to 'Lib/test/test_importlib/import_')
-rw-r--r--Lib/test/test_importlib/import_/test_path.py7
1 files changed, 6 insertions, 1 deletions
diff --git a/Lib/test/test_importlib/import_/test_path.py b/Lib/test/test_importlib/import_/test_path.py
index 8b9c77d..d82b7f6 100644
--- a/Lib/test/test_importlib/import_/test_path.py
+++ b/Lib/test/test_importlib/import_/test_path.py
@@ -98,13 +98,18 @@ class FinderTests(unittest.TestCase):
new_path_hooks = [zipimport.zipimporter,
_bootstrap.FileFinder.path_hook(
*_bootstrap._get_supported_file_loaders())]
- with util.uncache('email'):
+ missing = object()
+ email = sys.modules.pop('email', missing)
+ try:
with util.import_state(meta_path=sys.meta_path[:],
path=new_path,
path_importer_cache=new_path_importer_cache,
path_hooks=new_path_hooks):
module = import_module('email')
self.assertIsInstance(module, ModuleType)
+ finally:
+ if email is not missing:
+ sys.modules['email'] = email
def test_main():