https://pantsbuild.org/ logo
#general
Title
# general
s

swift-river-73520

05/15/2023, 8:50 PM
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

bitter-ability-32190

05/15/2023, 9:06 PM
Yes it does. And it should because those fixtures could set
autouse=True
(Or use the pytest hooks for test collection, reporting, etc...)
c

curved-television-6568

05/15/2023, 9:21 PM
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

swift-river-73520

05/15/2023, 9:22 PM
got it, thanks for the help!
2 Views