How to change Tox command with command-line parameters
Asked Answered
B

2

13

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.

Birgitbirgitta answered 11/12, 2015 at 20:17 Comment(0)
A
18

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.

Arri answered 27/11, 2016 at 16:36 Comment(1)
I've been looking for this answer 45 minutes :) Thanks a lot !Ryder
C
0

This looks like it's the latest doc for tox positional arguments: Substitions for positional arguments in commands

Conflagrant answered 11/7, 2023 at 21:49 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.