Skip to content

Python: wildcards in pytest testpaths are compared as literal paths #208

Closed

Description

@FredApps

isPytestFile (src/repo/adapters/python.ts) treats every testpaths entry as a literal directory prefix. pytest expands each entry with glob.iglob(entry, recursive=True), so wildcards are allowed.

pyproject.toml              [tool.pytest.ini_options]
                            testpaths = ["tests", "pkgs/*/tests"]
                            pythonpath = ["pkgs/a"]
tests/test_t.py
pkgs/a/lib.py
pkgs/a/tests/test_lib.py    from lib import f

python -m pytest --co collects both tests/test_t.py and pkgs/a/tests/test_lib.py.

Expected: pkgs/a/tests/test_lib.py is a test file, and a change to pkgs/a/lib.py selects it.

Actual: pythonTests is ["tests/test_t.py"]. The change to pkgs/a/lib.py gives fallbackRequired: false and no affected tests. With only testpaths = ["pkgs/*/tests"], the empty test universe falls back instead.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions