如何只用 tox 测试一个函数?

How to test only one function with tox?

我正在学习使用 tox 编写测试。如何使用 tox 只测试一个函数?例如,如果我只想测试来自 tests/test_backup_cmd.py of django-backup extension

test_simple_backup_generation

如果您在 tox.ini 中定义参数 {posargs},您可以在执行期间传入参数。在 py.test 的情况下,其中

py.test -k test_simple_backup_generation

只会测试一个功能:

[tox]
envlist = py27,py35
[testenv]
deps=pytest
commands=
    pip install -e .[tests,docs]
    py.test {posargs}

和运行喜欢

tox -- -k test_simple_backup_generation