diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2021-09-13 07:49:53 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-09-13 07:49:53 (GMT) |
commit | 851811f5772c43f72f445e2ce1ac3ea9da951ae3 (patch) | |
tree | 4178e52377f5bfd4f9e94dc5261eb0a6e05ef6cc /Lib/test/test_email | |
parent | c78d5ca3806d02e26f9f3fa92ff567f0805eac4c (diff) | |
download | cpython-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/test_email')
-rw-r--r-- | Lib/test/test_email/torture_test.py | 26 |
1 files changed, 10 insertions, 16 deletions
diff --git a/Lib/test/test_email/torture_test.py b/Lib/test/test_email/torture_test.py index e72a146..9cf9362 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() |