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.
This commit is contained in:
Serhiy Storchaka 2021-09-13 10:49:53 +03:00 committed by GitHub
parent c78d5ca380
commit 851811f577
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
49 changed files with 80 additions and 93 deletions

View file

@ -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()