Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to change Tox command with command-line parameters

How do you append options to the command Tox runs by appending that option to Tox? Specifically, how do you run a specific Django unittest with Tox?

I'm trying to wrap Tox around some Django unittests, and I can run all unittests with tox, which runs django-admin.py test --settings=myapp.tests.settings myapp.tests.Tests.

However, I'd like to run a specific test at myapp.tests.Tests.test_somespecificthing, which would mean telling Tox to append ".test_somespecificthing" to the end of the command it runs, but I can't figure out how to do this.

The docs say to use "-- " to pass in additional arguments to the underlying command, but this doesn't seem to work.

like image 944
Cerin Avatar asked Dec 11 '15 20:12

Cerin


People also ask

What is tox Envlist?

[tox]envlist is only a default — a list of environments to run when tox is invoked without option -e and without TOXENV environment variable. Once you use tox -e [tox]envlist is ignored. You can run local environment with different python versions, but I don't know any way to run it multiple times.

What is tox command?

tox is a command-line driven automated testing tool for Python, based on the use of virtualenv . It can be used for both manually-invoked testing from the desktop, or continuous testing within continuous integration frameworks such as Jenkins or Travis CI.


1 Answers

Try adding {posargs} in the commands section of your tox.ini, like this:

commands =
    python manage.py test {posargs}

Then at the command line, something like:

tox -- --pattern='some_specific_test.py'

Everything after the -- will be substituted in as {posargs}.

Read the official documentation here.

like image 89
Michael Stokley Avatar answered Oct 25 '22 08:10

Michael Stokley