does Pants automatically include `conftest.py` in ...
# general
s
does Pants automatically include
conftest.py
in the same way pytest does, even if a test target doesn't refer to any fixtures in
conftest.py
? I am transitioning a repo to use pants, and when I run a target that doesn't use any fixtures it still seems to want to include the conftest file and all its dependencies. Is the only way around this to put the test in a folder that doesn't have conftest.py in one of its parent folders? for example the tests are structured like this: tests/ tests/confest.py tests/foo/bar/test_file.py #doesn't refer to any fixtures in tests/conftest.py
b
Yes it does. And it should because those fixtures could set
autouse=True
(Or use the pytest hooks for test collection, reporting, etc...)
c
Is the only way around this to put the test in a folder that doesn’t have conftest.py in one of its parent folders?
If you want to preserve the directory structure, you may be able to exclude it with
!!tests/conftest.py
See “ignore dependencies with ! and !!” in https://www.pantsbuild.org/docs/targets#dependencies-field N.b. I’ve only used this with 3rdparty requirements, not the conftest.py file, so not sure if it will actually work as desired.
s
got it, thanks for the help!