mirror of
https://github.com/python/cpython.git
synced 2025-11-01 10:45:30 +00:00
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:
parent
c78d5ca380
commit
851811f577
49 changed files with 80 additions and 93 deletions
|
|
@ -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()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue