Skip to content

gh-158681: Document that regrtest rejects test_main() and loads unittest suites - #158682

Open
bazhil wants to merge 6 commits into
python:mainfrom
bazhil:doc-regrtest-unittest-loader
Open

bazhil wants to merge 6 commits into
python:mainfrom
bazhil:doc-regrtest-unittest-loader

Conversation

@bazhil

@bazhil bazhil commented Oct 3, 2026 •

Copy link
Copy Markdown
Contributor

#158681

Doc/library/test.rst said that python -m test calls a module-level test_main() when it exists, and otherwise loads tests with unittest.TestLoader.loadTestsFromModule. It also told readers to call test.support.reap_children() at the end of test_main. The docstring of reap_children() said the same thing.

libregrtest does not call test_main(). If the imported module defines it, Lib/test/libregrtest/single.py raises Exception. regrtest reports the module as failed with an uncaught exception (stderr: test <name> crashed; summary: failed (uncaught exception)). Tests are loaded with loadTestsFromModule, which collects TestCase classes and, when the module defines load_tests, runs the suite that function returns. Packages use load_tests, usually via test.support.load_package_tests, to add tests from submodules. reap_children() is called from setUp(), tearDown(), and tearDownModule().

The runner is unchanged. This updates the library page and the reap_children() docstring.

@python-cla-bot

python-cla-bot Bot commented Oct 3, 2026 •

Copy link
Copy Markdown

The following commit authors need to sign the Contributor License Agreement:

CLA not signed

@read-the-docs-community

read-the-docs-community Bot commented Oct 3, 2026 •

Copy link
Copy Markdown

Documentation build overview

📚 cpython-previews | 🛠️ Build #34925593 | 📁 Comparing 6ee9120 against main (1b015e6)

  🔍 Preview build  

2 files changed
± library/test.html
± whatsnew/changelog.html

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant