Currently every test module in the distutils.tests package has function test_suite() which explicitly creates unittest.TestLoader and loads it by calling loadTestsFromTestCase() for every test class. Then test_main merges all these tests and runs them with test.support.run_unittest(). But test.support.run_unittest() will be removed (see #111165). Also, the distutils.tests package cannot be run via unittest, it does not search tests in submodules by default, and when run tests in submodules separately via unittest, it misses some doctests because they cannot be automatically loaded.
The following PR contains the following changes:
- use
unittest.main() instead of run_unittest(test_suite()) to run tests from modules via the CLI
- add explicit
load_tests() to load doctests
- use
test.support.load_package_tests() to load tests in submodules of distutils.tests
- removes no longer needed
test_suite() functions
Linked PRs
Currently every test module in the
distutils.testspackage has functiontest_suite()which explicitly createsunittest.TestLoaderand loads it by callingloadTestsFromTestCase()for every test class. Thentest_mainmerges all these tests and runs them withtest.support.run_unittest(). Buttest.support.run_unittest()will be removed (see #111165). Also, thedistutils.testspackage cannot be run viaunittest, it does not search tests in submodules by default, and when run tests in submodules separately viaunittest, it misses some doctests because they cannot be automatically loaded.The following PR contains the following changes:
unittest.main()instead ofrun_unittest(test_suite())to run tests from modules via the CLIload_tests()to load docteststest.support.load_package_tests()to load tests in submodules ofdistutils.teststest_suite()functionsLinked PRs