Repository navigation
gh-158681: Document that regrtest rejects test_main() and loads unittest suites - #158682
Conversation
Documentation build overview
27 files changed ·
|
|
The commit email doesn't seem to be a valid address. Please use a valid one. |
fd30727 to
58b6171
Compare
Fixed |
58b6171 to
aabe5ea
Compare
StanFromIreland
left a comment
There was a problem hiding this comment.
Some suggested wording tweaks.
| """Call this from a test's setUp(), tearDown(), or tearDownModule() | ||
| when the test starts subprocesses. This will help ensure that no extra | ||
| children (zombies) stick around to hog resources and create problems when | ||
| looking for refleaks. | ||
| """ |
There was a problem hiding this comment.
| """Call this from a test's setUp(), tearDown(), or tearDownModule() | |
| when the test starts subprocesses. This will help ensure that no extra | |
| children (zombies) stick around to hog resources and create problems when | |
| looking for refleaks. | |
| """ | |
| """Call this from setUp(), tearDown(), or tearDownModule() in tests | |
| that start subprocesses. This will help ensure that no extra children | |
| (zombies) stick around to hog resources and create problems when | |
| looking for refleaks. | |
| """ |
| Call this from a test's :meth:`~unittest.TestCase.setUp`, | ||
| :meth:`~unittest.TestCase.tearDown`, or ``tearDownModule`` when the | ||
| test starts subprocesses. This will help ensure that no extra children | ||
| (zombies) stick around to hog resources and create problems when looking | ||
| for refleaks. |
There was a problem hiding this comment.
| Call this from a test's :meth:`~unittest.TestCase.setUp`, | |
| :meth:`~unittest.TestCase.tearDown`, or ``tearDownModule`` when the | |
| test starts subprocesses. This will help ensure that no extra children | |
| (zombies) stick around to hog resources and create problems when looking | |
| for refleaks. | |
| Call this from :meth:`~unittest.TestCase.setUp`, | |
| :meth:`~unittest.TestCase.tearDown`, or ``tearDownModule()`` in tests | |
| that start subprocesses. This will help ensure that no extra children | |
| (zombies) stick around to hog resources and create problems when looking | |
| for refleaks. |
| :mod:`!test` package. It does this by finding modules and packages whose names | ||
| start with ``test_``, importing each one, and loading its tests with | ||
| :meth:`unittest.TestLoader.loadTestsFromModule`. See the | ||
| :ref:`load_tests protocol <load_tests-protocol>` for how a module or package | ||
| can customize what is loaded. A module-level ``test_main()`` function is not | ||
| called. If a test module defines ``test_main``, :mod:`!test.regrtest` fails | ||
| that test. The names of | ||
| tests to execute may also be passed to the script. Specifying a single |
There was a problem hiding this comment.
| :mod:`!test` package. It does this by finding modules and packages whose names | |
| start with ``test_``, importing each one, and loading its tests with | |
| :meth:`unittest.TestLoader.loadTestsFromModule`. See the | |
| :ref:`load_tests protocol <load_tests-protocol>` for how a module or package | |
| can customize what is loaded. A module-level ``test_main()`` function is not | |
| called. If a test module defines ``test_main``, :mod:`!test.regrtest` fails | |
| that test. The names of | |
| tests to execute may also be passed to the script. Specifying a single | |
| :mod:`!test` package. It does this by finding modules and packages whose names | |
| start with ``test_``, importing each one, and loading its tests with | |
| :meth:`unittest.TestLoader.loadTestsFromModule`. See the | |
| :ref:`load_tests protocol <load_tests-protocol>` for how a module or package | |
| can customize what is loaded. Defining a module-level ``test_main()`` function | |
| is not supported and causes the test to fail. The names of tests to | |
| execute may also be passed to the script. Specifying a single |
|
Please don't force push. Also please apply suggestions, as it is clearer for reviewers whether something as been resolved (and if it has been modified while doing so). |
|
@bazhil please apply suggestions via the web interface, that way it's clear if they have been applied or not. Since you didn't do that, I now have to re-review again. |
|
@StanFromIreland I apologize for the inconvenience. I will proceed in exactly this way in the future. |
|
Thanks @bazhil for the PR, and @StanFromIreland for merging it 🌮🎉.. I'm working now to backport this PR to: 3.14. |
|
Thanks @bazhil for the PR, and @StanFromIreland for merging it 🌮🎉.. I'm working now to backport this PR to: 3.15. |
|
GH-159574 is a backport of this pull request to the 3.14 branch. |
|
GH-159575 is a backport of this pull request to the 3.15 branch. |
|
@aisk @StanFromIreland Thank you! |
|
#158681
Doc/library/test.rstsaid thatpython -m testcalls a module-leveltest_main()when it exists, and otherwise loads tests withunittest.TestLoader.loadTestsFromModule. It also told readers to calltest.support.reap_children()at the end oftest_main. The docstring ofreap_children()said the same thing.libregrtestdoes not calltest_main(). If the imported module defines it,Lib/test/libregrtest/single.pyraisesException. regrtest reports the module as failed with an uncaught exception (stderr:test <name> crashed; summary:failed (uncaught exception)). Tests are loaded withloadTestsFromModule, which collectsTestCaseclasses and, when the module definesload_tests, runs the suite that function returns. Packages useload_tests, usually viatest.support.load_package_tests, to add tests from submodules.reap_children()is called fromsetUp(),tearDown(), andtearDownModule().The runner is unchanged. This updates the library page and the
reap_children()docstring.