I'm learning to write tests with tox. How do I test only one function with tox? For example if I want to test only test_simple_backup_generation
from tests/test_backup_cmd.py
of django-backup
extension
Asked
Active
Viewed 1,045 times
2

Михаил Павлов
- 805
- 1
- 9
- 21
1 Answers
4
If you define a parameter {posargs}
in your tox.ini
you can pass in arguments during execution. In the case of py.test, where
py.test -k test_simple_backup_generation
would only test one function:
[tox]
envlist = py27,py35
[testenv]
deps=pytest
commands=
pip install -e .[tests,docs]
py.test {posargs}
and run like
tox -- -k test_simple_backup_generation

Nils Werner
- 34,832
- 7
- 76
- 98
-
Thanks for the answer. I have one more question on tox/py.test [here](http://stackoverflow.com/questions/39018056/how-do-the-arguments-are-being-passed-to-test-functions-in-tox-py-test). Can you please check it? – Михаил Павлов Aug 18 '16 at 12:21