Skip to content

[3.11] Use unittest to collect and run distutils tests #111309

@serhiy-storchaka

Description

@serhiy-storchaka

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    3.11only security fixestestsTests in the Lib/test dir

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions