Can I make the pytest doctrine module ignore the file?

We use pytest to test our project and have included --doctest-modules by default to compile all our doctrines from the whole project.

However, there is one wsgi.py that cannot be imported during the test collection, but I cannot force 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 works is to put the whole wsgi.py directory in norecursedirs in the pytest configuration file, but this explicitly hides the whole directory that I don't want.

Is there a way to force the doctest module to ignore only a specific file?

+5
source share
1 answer

You can use hook to conditionally exclude some folders from test detection. https://docs.pytest.org/en/latest/writing_plugins.html

 def pytest_ignore_collect(path, config): """ return True to prevent considering this path for collection. This hook is consulted for all files and directories prior to calling more specific hooks. """ 
+2
source

Source: https://habr.com/ru/post/1261978/


All Articles