Reputation: 69
I have a pytest project and a want to run tests from TWO python files. The project structure looks like this: at the root of the project there is a "tests" folder, it contains several folders "test_api1", "test_api2", "test_api3", each of them contains conftest.py and a test file.
tests:
Usually I run tests like this
python -m pytest -vs -k tests (if I want to run all tests from tests directory)
or like this
python -m pytest -vs -k test_api1.py (if I want to run a certain test).
But now I want to run tests from TWO certain files test_api1.py and test_api1.py. How can I do that?
Upvotes: 4
Views: 9060
Reputation: 472
Just add files that you want to run as positional arguments, e.g.:
python -m pytest tests/test_api1.py tests/test_api2.py
NOTE: you need to run pytest without -k
flag and hence use paths to the files instead of just filenames.
Upvotes: 7