[TIP] Running a single test with tox

Aaron Whitehouse lists at whitehouse.kiwi.nz
Thu Jul 30 08:05:21 PDT 2015


Hello,

I contribute to duplicity, which is a project that uses tox to make
run-tests run all tests against both Python version 2.6 and version 2.7.

I like to develop in a test-driven way, so am often running individual
tests or classes of tests, using (for example):
python setup.py test -s
testing.unit.test_selection.MatchingTest.test_tuple_include
(where the file holding the test is
[project]/testing/unit/test_selection.py, the class is MatchingTest and
the method is test_tuple_include)

When I use this command, however, it only tests against Python v2.7. It
would therefore be useful if I could ask tox to run the individual test,
so that it was tested against both Python 2.6 and 2.7.

I tried the command suggested here:
http://blog.jasonmeridth.com/posts/how-to-run-a-single-test-with-tox/
tox -e py26 --
duplicity/testing/unit/test_selection.py:MatchingTest.test_tuple_include
but this ran all tests.

Similarly, following the directions on here:
https://wiki.openstack.org/wiki/Testr
tox -epy27 --  '(MatchingTest)'
also ran all tests.

And finally, following:
http://openstack.10931.n7.nabble.com/Running-individual-UTs-with-TOX-td11301.html
tox -e py27 -- testing.unit.test_selection.MatchingTest.test_tuple_include
or
tox -e py27 -- test_selection.MatchingTest.test_tuple_include
also runs all the tests.

(Note that I do not actually want to restrict the test to just py26 or
py27, but that is what all the examples do and so I thought I'd try to
get that working first.)

I'm presumably doing something really obvious wrong, but I can't figure
it out, so would really appreciate a pointer!

I'm running tox version 1.7.2.

Many thanks in advance,

Aaron



More information about the testing-in-python mailing list