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: regrtest single TestClass/test_method
Type: enhancement Stage: resolved
Components: Tests Versions: Python 3.2
process
Status: closed Resolution: works for me
Dependencies: Superseder:
Assigned To: Nosy List: r.david.murray, sandro.tosi, techtonik
Priority: normal Keywords:

Created on 2010-04-07 09:19 by techtonik, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Messages (5)
msg102524 - (view) Author: anatoly techtonik (techtonik) Date: 2010-04-07 09:19
It would be convenient for debug to execute single test_method or TestClass. Running all tests in file can take a long time.
msg102525 - (view) Author: anatoly techtonik (techtonik) Date: 2010-04-07 09:20
regrtest [options] test_file.TestClass
regrtest [options] test_file.test_method
msg119808 - (view) Author: Sandro Tosi (sandro.tosi) * (Python committer) Date: 2010-10-28 19:19
Hello,
as explained in msg108109 (of issue9028) you can actually call a single test, or a single TestClass:

$ ./python -m unittest test.test_httpservers.BaseHTTPServerTestCase.test_handler
.
----------------------------------------------------------------------
Ran 1 test in 0.168s

OK
$ ./python -m unittest test.test_httpservers.BaseHTTPServerTestCase
..............
----------------------------------------------------------------------
Ran 14 tests in 1.132s

OK

I'm closing this report, but feel free to reopen it if you think I'm missing something.

Thanks,
Sandro
msg121049 - (view) Author: anatoly techtonik (techtonik) Date: 2010-11-12 17:25
Yes. You're missing the second case. In:
> regrtest [options] test_file.test_method

You don't specify class name. This saves some time you need to navigate and copy/paste name of container class. It will save more time if masks are used by default. To illustrate this let's introduce '-l' key that lists all found tests to test test discovery (no errors in this sentence).

> regrtest -l *des*
test_file.FancyRenameTests.test_no_*des*t_exists
test_file.FancyRenameTests.test_*des*t_exists
test_file.FancyRenameTests.test_*des*t_opened
test_file.GitFile*des*tTests.test_invalid
test_file.GitFile*des*tTests.test_readonly
test_*des*t.SomeClass.some_test
....

*stars* in results highlight matched substring.

Rationale: The most common operation when looking for tests to run is grep. You don't need to remember option name to specify mask - just use mask - it will run discovery and execute only tests found. '-l' key in test runner can be used to quickly grep available tests to find the exact name and run only it.
msg121108 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2010-11-13 03:50
I'm -1 on your second case.  That syntax is too magical, especially since a test method can appear on more than one test case.  

The additional pattern matching suggestion is more interesting, but it would be necessary to implement that in unittest, since test classes and methods can be created on the fly. I suggest opening a new issue against unittest to extend pattern matching to test case and test method names if you think that feature is valuable enough to add.

I agree with Sandro, I think the valid part of this request is satisfied by the unittest CLI.  It is true that more work needs to be done before all Python tests can be run successfully in this fashion, since some depend on regrtest features.  But making those fixes (moving useful regrtest features to unittest and eliminating the non-useful regrtest dependencies) is a better investment of resources than adding run-single-test support directly to regrtest, IMO.

If you want to submit a patch for first case, though, feel free to reopen this.  I doubt we'd reject it if you want to do the work.
History
Date User Action Args
2022-04-11 14:56:59adminsetgithub: 52579
2010-11-13 03:50:20r.david.murraysetstatus: open -> closed

versions: + Python 3.2, - Python 2.7
nosy: + r.david.murray

messages: + msg121108
resolution: fixed -> works for me
stage: resolved
2010-11-12 17:25:32techtoniksetstatus: closed -> open

messages: + msg121049
2010-10-28 19:19:23sandro.tosisetstatus: open -> closed

nosy: + sandro.tosi
messages: + msg119808

resolution: fixed
2010-04-07 09:20:07techtoniksetmessages: + msg102525
2010-04-07 09:19:16techtonikcreate