[issue30523] unittest: add --list-tests option to only display the list of test names, don't run tests

STINNER Victor report at bugs.python.org
Fri Jun 16 06:24:02 EDT 2017


STINNER Victor added the comment:

Yeah, Louie fixed most issues!

> I concur with Julien, the result should be printed to stdout.

Done by Louie. The code now uses a simple print().

> I tried:
>
> $ ./python -m unittest test.test_builtin --list-tests
> doctest.DocTestCase.runTest
> doctest.DocTestCase.runTest
> ...

Using Louie's implementation, it "just" works!

haypo at selma$ ./python -m test test_builtin --list-cases|grep ^builtins
builtins.bin
builtins.float.as_integer_ratio
...

Even if these test names are not fully qualified, they are accept by --match/--matchfile!

./python -m test test_builtin --match=builtins.bin -v
...
0:00:00 load avg: 0.12 [1/1] test_builtin
bin (builtins)
Doctest: builtins.bin ... ok
...

So it will be possible to implement my bisect feature on these doctests as well!

I pushed Louie Lu's implementation: add a new --list-cases option to regrtest. Serhiy proposed a different CLI:

* --list=methods
* --list=files
* --list=classes

But I chose to push Louie's patch anyway since its patch is super simple and doesn't break anything: you can still use the existing --list-tests to list test *files*. I don't need --list=classes yet, it may be added later.

Serhiy: I plan to backport --matchfile and --list-cases features to 2.7, 3.5 and 3.6 branches, once Louie writes the unit test I requested him. Are you ok with that?

I really need to get my bisect tool on all branches, because more and more often I have to bisect refernece leaks, tests leaking resources (files, leaking memory, etc.), etc. --matchfile and --list-cases are the key features to implement such bisection.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue30523>
_______________________________________


More information about the Python-bugs-list mailing list