We use pytest to test our project and have enabled --doctest-modules
by default to collect all of our doctests from across the project.
However there is one wsgi.py
which may not be imported during test collection, but I cant get pytest to ignore it.
I tried putting it in the collect_ignore
list in conftest.py
but apparently the doctest module does not use this list.
The only thing that does work is putting the whole directory of wsgi.py
into norecursedirs
in the pytest config file, but this obviously hides the whole directory, which I don't want.
Is there a way to make the doctest module ignore just a certain file?
You can use hook to conditionally exclude some folders from test discovery. https://docs.pytest.org/en/latest/writing_plugins.html