Question
How can I tell pytest to ignore all test files including conftest.py within a repository's git submodule as these tests and files are irrelevant to the parent repository's test suite?
Background
I have a number of git submodules in my project which house their own self contained testing configurations.
When I try to use pytest in the "parent" repository, I am getting this error because pytest is collecting the conftest.py files within my submodules.
>pytest
=================================================== ERRORS ===================================================
_______________________________________ ERROR collecting test session ________________________________________
Defining 'pytest_plugins' in a non-top-level conftest is no longer supported:
It affects the entire test suite instead of just below the conftest as expected.
C:\Users\user\git\project\submodule\conftest.py
Please move it to a top level conftest file at the rootdir:
C:\Users\user\git\project
For more information, visit:
https://docs.pytest.org/en/latest/deprecations.html#pytest-plugins-in-non-top-level-conftest-files
========================================== short test summary info =========================================== ERROR
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Interrupted: 1 error during collection !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! ============================================== 1 error in 0.45s ==============================================
My "parent" git repository structure looks like:
./.git
./project1/__main__.py
./project1/__init__.py
./project1/other_stuff/
./test/
./conftest.py
./setup.cfg
./submodule/.git
./submodule/project2/__main__.py
./submodule/project2/__init__.py
./submodule/project2/other_stuff/
./submodule/conftest.py
./submodule/setup.cfg
./submodule/test/
One (cumbersome) option may be to only run pytest with uninitialized submodules. However, if I do not initialize the git submodules then I cannot run integration tests with those libraries.