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

This commit is contained in:
Hai Shi 2020-08-04 00:41:24 +08:00 committed by GitHub
parent 488512bf49
commit a7f5d93bb6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
20 changed files with 154 additions and 132 deletions

View file

@ -5,6 +5,7 @@ import sys
import types
import pickle
from test import support
from test.support import import_helper
import test.test_importlib.util
import unittest
@ -848,7 +849,7 @@ class TestDiscovery(unittest.TestCase):
with unittest.mock.patch('builtins.__import__', _import):
# Since loader.discover() can modify sys.path, restore it when done.
with support.DirsOnSysPath():
with import_helper.DirsOnSysPath():
# Make sure to remove 'package' from sys.modules when done.
with test.test_importlib.util.uncache('package'):
suite = loader.discover('package')
@ -865,7 +866,7 @@ class TestDiscovery(unittest.TestCase):
with unittest.mock.patch('builtins.__import__', _import):
# Since loader.discover() can modify sys.path, restore it when done.
with support.DirsOnSysPath():
with import_helper.DirsOnSysPath():
# Make sure to remove 'package' from sys.modules when done.
with test.test_importlib.util.uncache('package'):
with self.assertRaises(TypeError) as cm:

View file

@ -2,7 +2,7 @@ import io
import sys
import textwrap
from test import support
from test.support import warnings_helper
import traceback
import unittest
@ -458,8 +458,8 @@ OldResult = type('OldResult', (object,), classDict)
class Test_OldTestResult(unittest.TestCase):
def assertOldResultWarning(self, test, failures):
with support.check_warnings(("TestResult has no add.+ method,",
RuntimeWarning)):
with warnings_helper.check_warnings(
("TestResult has no add.+ method,", RuntimeWarning)):
result = OldResult()
test.run(result)
self.assertEqual(len(result.failures), failures)