bpo-40275: Use new test.support helper submodules in tests (GH-21451)

This commit is contained in:
Hai Shi 2020-08-04 00:47:42 +08:00 committed by GitHub
parent a7f5d93bb6
commit bb0424b122
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
20 changed files with 324 additions and 278 deletions

View file

@ -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: