summaryrefslogtreecommitdiffstats
path: root/Lib/importlib/test/test_api.py
diff options
context:
space:
mode:
authorBrett Cannon <brett@python.org>2012-07-04 18:03:40 (GMT)
committerBrett Cannon <brett@python.org>2012-07-04 18:03:40 (GMT)
commit53089c6e91f6152bc43776587e82a0bbeb574fe0 (patch)
treea5052b92b84272ad1e79f68bdb4234e563defe9b /Lib/importlib/test/test_api.py
parent3bee1f1154218b6bdadfe4095ef4b52c3471df01 (diff)
downloadcpython-53089c6e91f6152bc43776587e82a0bbeb574fe0.zip
cpython-53089c6e91f6152bc43776587e82a0bbeb574fe0.tar.gz
cpython-53089c6e91f6152bc43776587e82a0bbeb574fe0.tar.bz2
Issue #15210: Greatly simplify the test for supporting importlib
working without _frozen_importlib by moving to an import over a direct access in sys.modules.
Diffstat (limited to 'Lib/importlib/test/test_api.py')
-rw-r--r--Lib/importlib/test/test_api.py17
1 files changed, 5 insertions, 12 deletions
diff --git a/Lib/importlib/test/test_api.py b/Lib/importlib/test/test_api.py
index 8431eab..ba2a721 100644
--- a/Lib/importlib/test/test_api.py
+++ b/Lib/importlib/test/test_api.py
@@ -1,7 +1,9 @@
from . import util
import imp
import importlib
+from importlib import machinery
import sys
+from test import support
import unittest
@@ -164,18 +166,9 @@ class FrozenImportlibTests(unittest.TestCase):
def test_no_frozen_importlib(self):
# Should be able to import w/o _frozen_importlib being defined.
- modules = {}
- for name in ('importlib', 'importlib.__init__', 'importlib._bootstrap',
- '_frozen_importlib'):
- try:
- modules[name] = sys.modules[name]
- del sys.modules[name]
- except KeyError:
- continue
- modules['_frozen_importlib'] = None
- import importlib
- for name, module in modules.items():
- sys.modules[name] = module
+ module = support.import_fresh_module('importlib', blocked=['_frozen_importlib'])
+ self.assertFalse(isinstance(module.__loader__,
+ machinery.FrozenImporter))
def test_main():