Reputation: 5877
I would like to be able to exclude instead of include certain python test files in the pytest.ini
configuration file. According to the docs including tests boils down to something like this:
# content of pytest.ini
[pytest]
pytest_files=test_main.py test_common.py
To exclude files however, only command line options are suggested:
--ignore=test_common.py
How can I actually select files to ignore at the pytest.ini
file level?
Upvotes: 14
Views: 19766
Reputation: 16815
You can add any command line options in pytest.ini
under addopts
. In your case this should work:
pytest.ini
[pytest]
addopts = --ignore=test_common.py
As has been noted in the comments, --ignore
takes a path (relative or absolute), not just a module name. From the output of pytest -h
:
--ignore=path ignore path during collection (multi-allowed).
--ignore-glob=path ignore path pattern during collection (multi-allowed).
Upvotes: 20