pytest2/src/_pytest
Ran Benita 31026a2df2 main: only include package parents in collection tree for --pyargs collection 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 #11904.
2024-03-02 20:26:02 +02:00
..
_code code: fix `IndexError` crash in `getstatementrange_ast` 2024-02-17 18:43:55 +02:00
_io [flake8-bugbear] Re-raise all exceptions with proper exception chaining 2024-02-04 19:27:23 +01:00
_py Enable flake8-pie 2024-02-09 11:08:33 +02:00
assertion Enable lint PGH004 - Use specific rule codes when using noqa 2024-02-09 11:14:36 +02:00
config New verbosity_test_case ini option (#11653) 2024-02-24 16:27:54 -03:00
mark ENH: Improve warning stacklevel (#12014) 2024-02-22 22:11:05 -08:00
__init__.py Run pre-commit on all files 2024-01-30 16:35:46 -03:00
_argcomplete.py Migrate from autoflake, black, isort, pyupgrade, flake8 and pydocstyle, to ruff 2024-02-02 09:27:00 +01:00
cacheprovider.py Migrate from autoflake, black, isort, pyupgrade, flake8 and pydocstyle, to ruff 2024-02-02 09:27:00 +01:00
capture.py [flake8-pyi] Add checks for flake8-pyi and fix existing 2024-02-04 19:27:23 +01:00
compat.py Revert sys.platform verification to simple comparison (#11998) 2024-02-17 16:10:21 -03:00
debugging.py Migrate from autoflake, black, isort, pyupgrade, flake8 and pydocstyle, to ruff 2024-02-02 09:27:00 +01:00
deprecated.py Migrate from autoflake, black, isort, pyupgrade, flake8 and pydocstyle, to ruff 2024-02-02 09:27:00 +01:00
doctest.py Add typing to `from_parent` return values (#11916) 2024-02-22 23:35:57 -08:00
faulthandler.py Migrate from autoflake, black, isort, pyupgrade, flake8 and pydocstyle, to ruff 2024-02-02 09:27:00 +01:00
fixtures.py fixtures: remove an unneeded suppress 2024-02-23 11:51:49 +02:00
freeze_support.py Run pre-commit on all files 2024-01-30 16:35:46 -03:00
helpconfig.py Migrate from autoflake, black, isort, pyupgrade, flake8 and pydocstyle, to ruff 2024-02-02 09:27:00 +01:00
hookspec.py Migrate from autoflake, black, isort, pyupgrade, flake8 and pydocstyle, to ruff 2024-02-02 09:27:00 +01:00
junitxml.py [ruff] Add 'consider-using-in' from pylint 2024-02-10 15:47:44 +01:00
legacypath.py Migrate from autoflake, black, isort, pyupgrade, flake8 and pydocstyle, to ruff 2024-02-02 09:27:00 +01:00
logging.py Add --log-file-mode option to the logging plugin, enabling appending to log-files (#11979) 2024-02-21 12:02:19 +00:00
main.py main: only include package parents in collection tree for --pyargs collection arguments 2024-03-02 20:26:02 +02:00
monkeypatch.py Migrate from autoflake, black, isort, pyupgrade, flake8 and pydocstyle, to ruff 2024-02-02 09:27:00 +01:00
nodes.py Add typing to `from_parent` return values (#11916) 2024-02-22 23:35:57 -08:00
outcomes.py Migrate from autoflake, black, isort, pyupgrade, flake8 and pydocstyle, to ruff 2024-02-02 09:27:00 +01:00
pastebin.py Migrate from autoflake, black, isort, pyupgrade, flake8 and pydocstyle, to ruff 2024-02-02 09:27:00 +01:00
pathlib.py Migrate from autoflake, black, isort, pyupgrade, flake8 and pydocstyle, to ruff 2024-02-02 09:27:00 +01:00
py.typed Publish our types 2020-07-04 13:18:15 +03:00
pytester.py [ruff] Fix all consider [*cats, garfield] instead of cats + [garfield] 2024-02-02 15:18:38 +01:00
pytester_assertions.py Run pre-commit on all files 2024-01-30 16:35:46 -03:00
python.py Add typing to `from_parent` return values (#11916) 2024-02-22 23:35:57 -08:00
python_api.py compat: get rid of STRING_TYPES 2024-02-03 18:38:38 +02:00
python_path.py Rename ``pythonpath`` plugin to ``python_path`` 2022-02-09 10:03:20 +02:00
recwarn.py recwarn: fix pytest.warns handling of Warnings with multiple arguments 2024-02-16 14:14:24 +02:00
reports.py Migrate from autoflake, black, isort, pyupgrade, flake8 and pydocstyle, to ruff 2024-02-02 09:27:00 +01:00
runner.py runner: add support for `sys.last_exc` for post-mortem debugging on Python>=3.12 2024-02-23 15:59:32 +02:00
scope.py Migrate from autoflake, black, isort, pyupgrade, flake8 and pydocstyle, to ruff 2024-02-02 09:27:00 +01:00
setuponly.py Migrate from autoflake, black, isort, pyupgrade, flake8 and pydocstyle, to ruff 2024-02-02 09:27:00 +01:00
setupplan.py Migrate from autoflake, black, isort, pyupgrade, flake8 and pydocstyle, to ruff 2024-02-02 09:27:00 +01:00
skipping.py Migrate from autoflake, black, isort, pyupgrade, flake8 and pydocstyle, to ruff 2024-02-02 09:27:00 +01:00
stash.py Migrate from autoflake, black, isort, pyupgrade, flake8 and pydocstyle, to ruff 2024-02-02 09:27:00 +01:00
stepwise.py Migrate from autoflake, black, isort, pyupgrade, flake8 and pydocstyle, to ruff 2024-02-02 09:27:00 +01:00
terminal.py New verbosity_test_case ini option (#11653) 2024-02-24 16:27:54 -03:00
threadexception.py Migrate from autoflake, black, isort, pyupgrade, flake8 and pydocstyle, to ruff 2024-02-02 09:27:00 +01:00
timing.py Migrate from autoflake, black, isort, pyupgrade, flake8 and pydocstyle, to ruff 2024-02-02 09:27:00 +01:00
tmpdir.py Migrate from autoflake, black, isort, pyupgrade, flake8 and pydocstyle, to ruff 2024-02-02 09:27:00 +01:00
unittest.py Add typing to `from_parent` return values (#11916) 2024-02-22 23:35:57 -08:00
unraisableexception.py Migrate from autoflake, black, isort, pyupgrade, flake8 and pydocstyle, to ruff 2024-02-02 09:27:00 +01:00
warning_types.py Migrate from autoflake, black, isort, pyupgrade, flake8 and pydocstyle, to ruff 2024-02-02 09:27:00 +01:00
warnings.py Migrate from autoflake, black, isort, pyupgrade, flake8 and pydocstyle, to ruff 2024-02-02 09:27:00 +01:00