summaryrefslogtreecommitdiffstats
path: root/Lib/test/support
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2021-09-13 07:49:53 (GMT)
committerGitHub <noreply@github.com>2021-09-13 07:49:53 (GMT)
commit851811f5772c43f72f445e2ce1ac3ea9da951ae3 (patch)
tree4178e52377f5bfd4f9e94dc5261eb0a6e05ef6cc /Lib/test/support
parentc78d5ca3806d02e26f9f3fa92ff567f0805eac4c (diff)
downloadcpython-851811f5772c43f72f445e2ce1ac3ea9da951ae3.zip
cpython-851811f5772c43f72f445e2ce1ac3ea9da951ae3.tar.gz
cpython-851811f5772c43f72f445e2ce1ac3ea9da951ae3.tar.bz2
bpo-5846: Do not use obsolete unittest functions. (GH-28303)
Get rid of use of makeSuite() and findTestCases(). Also make test_math and test_threading_local discoverable.
Diffstat (limited to 'Lib/test/support')
-rw-r--r--Lib/test/support/__init__.py5
-rw-r--r--Lib/test/support/testresult.py2
2 files changed, 4 insertions, 3 deletions
diff --git a/Lib/test/support/__init__.py b/Lib/test/support/__init__.py
index a86bfca..89f5e5a 100644
--- a/Lib/test/support/__init__.py
+++ b/Lib/test/support/__init__.py
@@ -1108,17 +1108,18 @@ def _compile_match_function(patterns):
def run_unittest(*classes):
"""Run tests from unittest.TestCase-derived classes."""
valid_types = (unittest.TestSuite, unittest.TestCase)
+ loader = unittest.TestLoader()
suite = unittest.TestSuite()
for cls in classes:
if isinstance(cls, str):
if cls in sys.modules:
- suite.addTest(unittest.findTestCases(sys.modules[cls]))
+ suite.addTest(loader.loadTestsFromModule(sys.modules[cls]))
else:
raise ValueError("str arguments must be keys in sys.modules")
elif isinstance(cls, valid_types):
suite.addTest(cls)
else:
- suite.addTest(unittest.makeSuite(cls))
+ suite.addTest(loader.loadTestsFromTestCase(cls))
_filter_suite(suite, match_test)
_run_suite(suite)
diff --git a/Lib/test/support/testresult.py b/Lib/test/support/testresult.py
index 6f2edda..2cd1366 100644
--- a/Lib/test/support/testresult.py
+++ b/Lib/test/support/testresult.py
@@ -173,7 +173,7 @@ if __name__ == '__main__':
raise RuntimeError('error message')
suite = unittest.TestSuite()
- suite.addTest(unittest.makeSuite(TestTests))
+ suite.addTest(unittest.TestLoader().loadTestsFromTestCase(TestTests))
stream = io.StringIO()
runner_cls = get_test_runner_class(sum(a == '-v' for a in sys.argv))
runner = runner_cls(sys.stdout)