Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
main: only include package parents in collection tree for --pyargs co…
…llection arguments (diff better viewed ignoring whitespace) In pytest<8, the collection tree for `pyargs` arguments in an invocation like this: pytest --collect-only --pyargs pyflakes.test.test_undefined_names looked like this: ``` <Package test> <Module test_undefined_names.py> <UnitTestCase Test> <TestCaseFunction test_annotationUndefined> ... snipped ... ``` The pytest 8 collection improvements changed it to this: ``` <Dir pytest> <Dir .tox> <Dir venv> <Dir lib> <Dir python3.11> <Dir site-packages> <Package pyflakes> <Package test> <Module test_undefined_names.py> <UnitTestCase Test> <TestCaseFunction test_annotationUndefined> ... snipped ... ``` Besides being egregious (and potentially even worse than the above, going all the way to the root, for system-installed packages, as is apparently common in CI), this also caused permission errors when trying to probe some of those intermediate directories. This change makes `--pyargs` arguments no longer try to add parent directories to the collection tree according to the `--confcutdir` like they're regular arguments. Instead, only add the parents that are in the import path. This now looks like this: ``` <Package .tox/venv/lib/python3.11/site-packages/pyflakes> <Package test> <Module test_undefined_names.py> <UnitTestCase Test> <TestCaseFunction test_annotationUndefined> ... snipped ... ``` Fix pytest-dev#11904.
- Loading branch information