[3.9] bpo-45229: Remove test_main in many tests (GH-28405) (GH-28456)

Instead of explicitly enumerate test classes for run_unittest()
use the unittest ability to discover tests. This also makes these
tests discoverable and runnable with unittest.

load_tests() can be used for dynamic generating tests and adding
doctests. setUpModule(), tearDownModule() and addModuleCleanup()
can be used for running code before and after all module tests..
(cherry picked from commit 40348acc18)
This commit is contained in:
Serhiy Storchaka 2021-09-20 09:34:52 +03:00 committed by GitHub
parent 41e2a31c13
commit 5822ab672a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
61 changed files with 210 additions and 471 deletions

View file

@ -1569,20 +1569,11 @@ class TestInternalUtilities(unittest.TestCase):
self.assertIsNone(self._get_revised_path(trailing_argv0dir))
@reap_threads
def test_main():
try:
test.support.run_unittest(PydocDocTest,
PydocImportTest,
TestDescriptions,
PydocServerTest,
PydocUrlHandlerTest,
TestHelper,
PydocWithMetaClasses,
TestInternalUtilities,
)
finally:
reap_children()
def setUpModule():
thread_info = test.support.threading_setup()
unittest.addModuleCleanup(test.support.threading_cleanup, *thread_info)
unittest.addModuleCleanup(reap_children)
if __name__ == "__main__":
test_main()
unittest.main()