-
-
Notifications
You must be signed in to change notification settings - Fork 674
Description
Describe the bug
Per pytest-dev/pytest#11261, as of at least pytest 8.5 (though StackOverflow reports this started with 7.4 and I've seen it with 8.3) pytest no longer just looks up the directory tree looking for conftest.py files. Instead it either walks up the directory tree to the level of --confcutdir and no higher or, if that isn't set it walks up to the first "project marker file" (e.g. a pytest.ini, pyproject.toml, etc.) and stops there. If --confcutdir isn't set and no project marker file is found it doesn't walk up the directory tree at all (presumably for security as that might allow anybody to add code outside the project that would get executed).
Currently Pants does not set --confcutdir so if users manually upgrade pytest their conftest.py files no longer get run.
Pants version
I'm using 2.28.0 but, AFAIK, all version are affected.
OS
Encountered on Linux but, per above, I think all versions are affected.
Additional info
there's a long Slack thread about this here: https://pantsbuild.slack.com/archives/C046T6T9U/p1760658668479529
At the end of that thread, @benjyw suggested:
And if you feel like tackling it, it would be pretty straightforward, to update pytest_args in src/python/pants/backend/python/goals/pytest_runner.py
--confcutdir=./src should do it