summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_importlib/test_api.py
diff options
context:
space:
mode:
authorHai Shi <shihai1992@gmail.com>2020-08-04 15:53:12 (GMT)
committerGitHub <noreply@github.com>2020-08-04 15:53:12 (GMT)
commitc7decc27d529c04a4e6b2922e3f3f9419b920f63 (patch)
tree9bcb971af68ed2e08f4aa4001412d38520194cff /Lib/test/test_importlib/test_api.py
parent604bba1f8fe32479c89b9824b2231cc4480dd110 (diff)
downloadcpython-c7decc27d529c04a4e6b2922e3f3f9419b920f63.zip
cpython-c7decc27d529c04a4e6b2922e3f3f9419b920f63.tar.gz
cpython-c7decc27d529c04a4e6b2922e3f3f9419b920f63.tar.bz2
bpo-40275: Use new test.support helper submodules in tests (GH-21727)
Diffstat (limited to 'Lib/test/test_importlib/test_api.py')
-rw-r--r--Lib/test/test_importlib/test_api.py18
1 files changed, 10 insertions, 8 deletions
diff --git a/Lib/test/test_importlib/test_api.py b/Lib/test/test_importlib/test_api.py
index 0fb1346..fd60634 100644
--- a/Lib/test/test_importlib/test_api.py
+++ b/Lib/test/test_importlib/test_api.py
@@ -7,6 +7,8 @@ machinery = test_util.import_importlib('importlib.machinery')
import os.path
import sys
from test import support
+from test.support import import_helper
+from test.support import os_helper
import types
import unittest
import warnings
@@ -200,7 +202,7 @@ class ReloadTests:
def test_reload_modules(self):
for mod in ('tokenize', 'time', 'marshal'):
with self.subTest(module=mod):
- with support.CleanImport(mod):
+ with import_helper.CleanImport(mod):
module = self.init.import_module(mod)
self.init.reload(module)
@@ -221,7 +223,7 @@ class ReloadTests:
self.assertEqual(reloaded.spam, 3)
def test_reload_missing_loader(self):
- with support.CleanImport('types'):
+ with import_helper.CleanImport('types'):
import types
loader = types.__loader__
del types.__loader__
@@ -232,7 +234,7 @@ class ReloadTests:
self.assertEqual(reloaded.__loader__.path, loader.path)
def test_reload_loader_replaced(self):
- with support.CleanImport('types'):
+ with import_helper.CleanImport('types'):
import types
types.__loader__ = None
self.init.invalidate_caches()
@@ -244,9 +246,9 @@ class ReloadTests:
def test_reload_location_changed(self):
name = 'spam'
- with support.temp_cwd(None) as cwd:
+ with os_helper.temp_cwd(None) as cwd:
with test_util.uncache('spam'):
- with support.DirsOnSysPath(cwd):
+ with import_helper.DirsOnSysPath(cwd):
# Start as a plain module.
self.init.invalidate_caches()
path = os.path.join(cwd, name + '.py')
@@ -257,7 +259,7 @@ class ReloadTests:
'__cached__': cached,
'__doc__': None,
}
- support.create_empty_file(path)
+ os_helper.create_empty_file(path)
module = self.init.import_module(name)
ns = vars(module).copy()
loader = ns.pop('__loader__')
@@ -295,9 +297,9 @@ class ReloadTests:
def test_reload_namespace_changed(self):
name = 'spam'
- with support.temp_cwd(None) as cwd:
+ with os_helper.temp_cwd(None) as cwd:
with test_util.uncache('spam'):
- with support.DirsOnSysPath(cwd):
+ with import_helper.DirsOnSysPath(cwd):
# Start as a namespace package.
self.init.invalidate_caches()
bad_path = os.path.join(cwd, name, '__init.py')