问题描述
如何将选项附加到命令 Tox ,方法是将该选项附加到Tox ?具体来说,您如何使用Tox运行特定的Django单元测试?
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?
我正在尝试将Tox封装在一些Django单元测试中,并且我可以使用运行django-admin.py test --settings=myapp.tests.settings myapp.tests.Tests
的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
.
但是,我想在myapp.tests.Tests.test_somespecificthing
上运行特定的测试,这意味着告诉Tox将".test_somespecificthing"附加到它运行的命令的末尾,但是我不知道该怎么做.
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.
推荐答案
尝试在tox.ini的命令部分中添加{posargs}
,如下所示:
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'
--
之后的所有内容都将替换为{posargs}
.
Everything after the --
will be substituted in as {posargs}
.
在此处 >.
这篇关于如何使用命令行参数更改Tox命令的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!