This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Modify regrtest to make test_main optional
Type: enhancement Stage: resolved
Components: Versions: Python 3.3
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: michael.foord, pitrou, python-dev, r.david.murray
Priority: normal Keywords: patch

Created on 2012-04-08 23:16 by r.david.murray, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
dont_require_test_main.patch r.david.murray, 2012-04-08 23:16 review
Messages (4)
msg157816 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2012-04-08 23:16
The attached patch makes 'test_main' optional for stdlib tests.  If a test module does not have a 'test_main', regrtest will use the unittest loadTestsFromModule loader to load the tests.

This moves us further in the direction of using normal unittest facilities instead of specialized regrtest ones.  Any test module that can be correctly run currently using python unittest -m test.test_xxx could be converted to use this by simply deleting its test_main, thus no longer requiring manual maintenance of the list of tests to run.  Not all tests can be converted that easily, however, since test_main sometimes does some additional things (such as reap_children or reap_threads).
msg157823 - (view) Author: Michael Foord (michael.foord) * (Python committer) Date: 2012-04-08 23:39
Looks good to me. Note that if module level setup and teardown is needed for running tests then it should be possible to do this with setUpModule and tearDownModule functions (unless those should *only* be done when running under regrtest).
msg157829 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2012-04-09 01:52
I can't imagine when you'd *not* want setUpModule/tearDownModule to run, so that's a reasonable conversion path.  The other path for reap_children and reap_threads would be to apply them to the individual classes that require them within the test module.  Which you do depends on how many test classes need the cleanups, I think.

I'm sure there will be other subtleties to be solved for other modules.  Note that I'm not advocating anyone go through and wholesale convert test modules.  But I think any time someone would otherwise have to update the list of tests in test_main, converting that test to eliminate test_main should be considered.
msg157843 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2012-04-09 13:13
New changeset eff551437abd by R David Murray in branch 'default':
#14533: if a test has no test_main, use loadTestsFromModule.
http://hg.python.org/cpython/rev/eff551437abd
History
Date User Action Args
2022-04-11 14:57:28adminsetgithub: 58738
2012-04-09 13:14:12r.david.murraysetstatus: open -> closed
resolution: fixed
stage: resolved
2012-04-09 13:13:13python-devsetnosy: + python-dev
messages: + msg157843
2012-04-09 01:52:01r.david.murraysetmessages: + msg157829
2012-04-08 23:39:01michael.foordsetmessages: + msg157823
2012-04-08 23:16:47r.david.murraycreate