From 851811f5772c43f72f445e2ce1ac3ea9da951ae3 Mon Sep 17 00:00:00 2001 From: Serhiy Storchaka Date: Mon, 13 Sep 2021 10:49:53 +0300 Subject: 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. --- Lib/test/test_email/torture_test.py | 26 ++++++++++---------------- 1 file changed, 10 insertions(+), 16 deletions(-) (limited to 'Lib/test/test_email/torture_test.py') diff --git a/Lib/test/test_email/torture_test.py b/Lib/test/test_email/torture_test.py index e72a146eca..9cf9362c9b 100644 --- a/Lib/test/test_email/torture_test.py +++ b/Lib/test/test_email/torture_test.py @@ -12,7 +12,6 @@ import unittest from io import StringIO from test.test_email import TestEmailBase -from test.support import run_unittest import email from email import __file__ as testfile @@ -24,10 +23,11 @@ def openfile(filename): return open(path, 'r') # Prevent this test from running in the Python distro -try: - openfile('crispin-torture.txt') -except OSError: - raise unittest.SkipTest +def setUpModule(): + try: + openfile('crispin-torture.txt') + except OSError: + raise unittest.SkipTest @@ -117,17 +117,11 @@ def _testclasses(): return [getattr(mod, name) for name in dir(mod) if name.startswith('Test')] -def suite(): - suite = unittest.TestSuite() +def load_tests(loader, tests, pattern): + suite = loader.suiteClass() for testclass in _testclasses(): - suite.addTest(unittest.makeSuite(testclass)) + suite.addTest(loader.loadTestsFromTestCase(testclass)) return suite - -def test_main(): - for testclass in _testclasses(): - run_unittest(testclass) - - -if __name__ == '__main__': - unittest.main(defaultTest='suite') +if __name__ == "__main__": + unittest.main() -- cgit v1.2.1