mirror of
https://github.com/python/cpython.git
synced 2025-11-01 06:01:29 +00:00
bpo-40275: Use new test.support helper submodules in tests (GH-21727)
This commit is contained in:
parent
604bba1f8f
commit
c7decc27d5
19 changed files with 58 additions and 46 deletions
|
|
@ -13,6 +13,7 @@
|
|||
from pathlib import Path, PurePath
|
||||
from test import support
|
||||
from test.support import import_helper
|
||||
from test.support import os_helper
|
||||
import unittest
|
||||
import sys
|
||||
import tempfile
|
||||
|
|
@ -159,9 +160,9 @@ def uncache(*names):
|
|||
@contextlib.contextmanager
|
||||
def temp_module(name, content='', *, pkg=False):
|
||||
conflicts = [n for n in sys.modules if n.partition('.')[0] == name]
|
||||
with support.temp_cwd(None) as cwd:
|
||||
with os_helper.temp_cwd(None) as cwd:
|
||||
with uncache(name, *conflicts):
|
||||
with support.DirsOnSysPath(cwd):
|
||||
with import_helper.DirsOnSysPath(cwd):
|
||||
invalidate_caches()
|
||||
|
||||
location = os.path.join(cwd, name)
|
||||
|
|
@ -397,7 +398,7 @@ def create_modules(*names):
|
|||
state_manager.__exit__(None, None, None)
|
||||
if uncache_manager is not None:
|
||||
uncache_manager.__exit__(None, None, None)
|
||||
support.rmtree(temp_dir)
|
||||
os_helper.rmtree(temp_dir)
|
||||
|
||||
|
||||
def mock_path_hook(*entries, importer):
|
||||
|
|
@ -573,8 +574,8 @@ def tearDownClass(cls):
|
|||
pass
|
||||
|
||||
def setUp(self):
|
||||
modules = support.modules_setup()
|
||||
self.addCleanup(support.modules_cleanup, *modules)
|
||||
modules = import_helper.modules_setup()
|
||||
self.addCleanup(import_helper.modules_cleanup, *modules)
|
||||
|
||||
|
||||
class ZipSetup(ZipSetupBase):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue