diff --git a/Lib/test/test_bdb.py b/Lib/test/test_bdb.py index ae168805678..9bce780e0d0 100644 --- a/Lib/test/test_bdb.py +++ b/Lib/test/test_bdb.py @@ -58,6 +58,9 @@ import linecache from contextlib import contextmanager from itertools import islice, repeat import test.support +from test.support import import_helper +from test.support import os_helper + class BdbException(Exception): pass class BdbError(BdbException): """Error raised by the Bdb instance.""" @@ -531,7 +534,7 @@ def run_test(modules, set_list, skip=None): @contextmanager def create_modules(modules): - with test.support.temp_cwd(): + with os_helper.temp_cwd(): sys.path.append(os.getcwd()) try: for m in modules: @@ -543,7 +546,7 @@ def create_modules(modules): yield finally: for m in modules: - test.support.forget(m) + import_helper.forget(m) sys.path.pop() def break_in_func(funcname, fname=__file__, temporary=False, cond=None): diff --git a/Lib/test/test_code_module.py b/Lib/test/test_code_module.py index 24db0ace801..226bc3a853b 100644 --- a/Lib/test/test_code_module.py +++ b/Lib/test/test_code_module.py @@ -4,9 +4,10 @@ import unittest from textwrap import dedent from contextlib import ExitStack from unittest import mock -from test import support +from test.support import import_helper -code = support.import_module('code') + +code = import_helper.import_module('code') class TestInteractiveConsole(unittest.TestCase): diff --git a/Lib/test/test_embed.py b/Lib/test/test_embed.py index 2b740521e72..31dc39fd9e8 100644 --- a/Lib/test/test_embed.py +++ b/Lib/test/test_embed.py @@ -1,5 +1,7 @@ # Run the tests in Programs/_testembed.c (tests for the CPython embedding APIs) from test import support +from test.support import import_helper +from test.support import os_helper import unittest from collections import namedtuple @@ -1339,8 +1341,8 @@ class InitConfigTests(EmbeddingTestsMixin, unittest.TestCase): # # The global path configuration (_Py_path_config) must be a copy # of the path configuration of PyInterpreter.config (PyConfig). - ctypes = support.import_module('ctypes') - _testinternalcapi = support.import_module('_testinternalcapi') + ctypes = import_helper.import_module('ctypes') + _testinternalcapi = import_helper.import_module('_testinternalcapi') def get_func(name): func = getattr(ctypes.pythonapi, name) @@ -1418,7 +1420,7 @@ class AuditingTests(EmbeddingTestsMixin, unittest.TestCase): returncode=1) def test_audit_run_interactivehook(self): - startup = os.path.join(self.oldcwd, support.TESTFN) + ".py" + startup = os.path.join(self.oldcwd, os_helper.TESTFN) + ".py" with open(startup, "w", encoding="utf-8") as f: print("import sys", file=f) print("sys.__interactivehook__ = lambda: None", file=f) @@ -1431,7 +1433,7 @@ class AuditingTests(EmbeddingTestsMixin, unittest.TestCase): os.unlink(startup) def test_audit_run_startup(self): - startup = os.path.join(self.oldcwd, support.TESTFN) + ".py" + startup = os.path.join(self.oldcwd, os_helper.TESTFN) + ".py" with open(startup, "w", encoding="utf-8") as f: print("pass", file=f) try: diff --git a/Lib/test/test_gzip.py b/Lib/test/test_gzip.py index 0f235d1805e..c3fa9b097f8 100644 --- a/Lib/test/test_gzip.py +++ b/Lib/test/test_gzip.py @@ -11,10 +11,12 @@ import sys import unittest from subprocess import PIPE, Popen from test import support +from test.support import import_helper +from test.support import os_helper from test.support import _4G, bigmemtest from test.support.script_helper import assert_python_ok, assert_python_failure -gzip = support.import_module('gzip') +gzip = import_helper.import_module('gzip') data1 = b""" int length=DEFAULTALLOC, err = Z_OK; PyObject *RetVal; @@ -29,7 +31,7 @@ data2 = b"""/* zlibmodule.c -- gzip-compatible data compression */ """ -TEMPDIR = os.path.abspath(support.TESTFN) + '-gzdir' +TEMPDIR = os.path.abspath(os_helper.TESTFN) + '-gzdir' class UnseekableIO(io.BytesIO): @@ -44,13 +46,13 @@ class UnseekableIO(io.BytesIO): class BaseTest(unittest.TestCase): - filename = support.TESTFN + filename = os_helper.TESTFN def setUp(self): - support.unlink(self.filename) + os_helper.unlink(self.filename) def tearDown(self): - support.unlink(self.filename) + os_helper.unlink(self.filename) class TestGzip(BaseTest): @@ -286,7 +288,7 @@ class TestGzip(BaseTest): self.test_write() with gzip.GzipFile(self.filename, 'r') as f: self.assertEqual(f.myfileobj.mode, 'rb') - support.unlink(self.filename) + os_helper.unlink(self.filename) with gzip.GzipFile(self.filename, 'x') as f: self.assertEqual(f.myfileobj.mode, 'xb') @@ -365,7 +367,7 @@ class TestGzip(BaseTest): self.assertEqual(isizeBytes, struct.pack('