Skip to content

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

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

bazhil wants to merge 7 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

All commit authors signed the Contributor License Agreement.

CLA signed

@read-the-docs-community

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

Copy link
Copy Markdown

Documentation build overview

📚 cpython-previews | 🛠️ Build #34931084 | 📁 Comparing 58b6171 against main (1b015e6)

  🔍 Preview build  

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

Comment thread Misc/NEWS.d/next/Documentation/2026-10-03-21-19-14.gh-issue-158681.fpovlg.rst Outdated
@aisk aisk added the skip news label Oct 4, 2026
@aisk

aisk commented Oct 4, 2026

Copy link
Copy Markdown
Member

The commit email doesn't seem to be a valid address. Please use a valid one.

@bazhil
bazhil force-pushed the doc-regrtest-unittest-loader branch from fd30727 to 58b6171 Compare October 4, 2026 16:51
@bazhil

bazhil commented Oct 4, 2026 •

Copy link
Copy Markdown
Contributor Author

The commit email doesn't seem to be a valid address. Please use a valid one.

Fixed

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.

2 participants