Conversation
…dev#13822) - Add helper function _is_system_temp_or_parent() to detect system temp dir - Modify determine_setup() to skip /tmp when searching for setup.py - Prevents pytest from incorrectly using /tmp as rootdir when /tmp/setup.py exists Fixes pytest-dev#13822
for more information, see https://pre-commit.ci
nicoddemus
left a comment
There was a problem hiding this comment.
Thanks @AddyM,
Could you please add a test to ensure this does not regress? You can monkeypatch tempfile.gettempdir() to avoid adding files to the system's temporary directory.
- Test verifies that setup.py in system temp dir is ignored - Uses monkeypatch to simulate /tmp/setup.py without touching system - Ensures rootdir detection works correctly
…com/addym/pytest into fix/issue-13822-tmp-setup-detection
Hello @nicoddemus , thanks a lot for the input , added a regression test .Please help in reviewing . Thanks |
for more information, see https://pre-commit.ci
|
@AddyM Could you please take a look at the failing checks? I think the codecov one is fine (I'm actually confused about it being marked as required?) as you can't easily test the corner case, but you should fix the lint issue and add a changelog entry. Also there seems to be a trivial conflict, would be great if you could resolve it (keeping both imports). |
Summary
Fixes #13822
When
/tmp/setup.pyexists on the system, pytest incorrectly identifies/tmpas the project root, causing test node IDs to include full paths under/tmpinstead of relative paths.Changes
_is_system_temp_or_parent()helper function to detect system temp directoriesdetermine_setup()to skip system temp directories when searching forsetup.pytempfile.gettempdir()for cross-platform compatibilityTesting
Backward Compatibility
--rootdirto override if needed