mirror of
https://github.com/python/cpython.git
synced 2025-08-03 08:34:29 +00:00
bpo-40275: Use new test.support helper submodules in tests (GH-21449)
This commit is contained in:
parent
488512bf49
commit
a7f5d93bb6
20 changed files with 154 additions and 132 deletions
|
@ -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:
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue