[Python-ideas] Easily reference a single unittest from cmdline

Giampaolo Rodola' g.rodola at gmail.com
Sat Dec 7 14:27:58 CET 2013


I just took a look at nosetests.
It provides a similar thing and lets you use a regular expression
(which indeed makes a lot more sense than using wildcards)
It works like this:

nosetests test/test_module -m test_name


--- Giampaolo
https://code.google.com/p/pyftpdlib/
https://code.google.com/p/psutil/
https://code.google.com/p/pysendfile/

On Sat, Dec 7, 2013 at 2:03 PM, Giampaolo Rodola' <g.rodola at gmail.com> wrote:
> During the development process it is very common to implement a new
> functionality, write a test for it and then run tests.
> I don't want to run *all* tests though, but only the new one which I just wrote.
> Currently unittest module lets you do this via cmdline with:
>
> python -m unittest test.test_module.TestClass.test_method
>
> This is not very practical though as you have to figure out the name
> of the module (easy) and the name of the test class (something which I
> *never* remember).
>
> Proposal is to allow a wildcard notation like this:
>
> python -m unittest test.test_module.*test_method*
> python -m unittest *test_method*
>
> What I expect from unittest is to execute only the test methods
> matching "*test_method*".
>
> This is related to an old proposal I raised 3 years ago:
> https://mail.python.org/pipermail/python-ideas/2010-August/007992.html
> After that dicussion I ended up coming up with a decorator for skipping tests:
> http://code.activestate.com/recipes/578234-unittestskip_others-decorator/?in=user-4178764
> ...but I never find it really practical and I ended up abandoning it.
>
> In retrospective, I think the cmdline is the right place from where
> such a thing should be controlled.
>
> Thoughts?
>
> --- Giampaolo
> https://code.google.com/p/pyftpdlib/
> https://code.google.com/p/psutil/
> https://code.google.com/p/pysendfile/


More information about the Python-ideas mailing list