Running a test with tox based on a keyword

Leo*_*z0r 2 pytest tox

I am using pytest with tox. I can run some of my tests with a keyword like this:

pytest -k <keyword> path/to/tests

Now it would be really convenient to be able to do this also with tox, as the environments there are clean and different python versions can be tested. However the nearest thing I have found is:

tox -- path/to/tests/test_very_specific_name.py:TestClass.test_func

This is not easy to type, so I rather just run tox without arguments and wait 2 minutes for everything to finish.

有没有办法根据带有 tox 的关键字运行单个测试?我试过:

tox -- -k <keyword>

这会导致大量导入错误。它似乎无法找到我的任何本地包含。这应该有效吗?

Leo*_*z0r 5

感谢博士的评论,我明白了。

-- 之后命令行上的所有内容都可以在 tox.ini 中用作 {posargs}。我用错了。我的 tox.ini 现在有这样一行:

commands = py.test {posargs} <test_folder>

现在它可以完美地与:

tox -- -k <keyword>