Skip to content

Collect sibling tests when parent and subfolder are both given - #14878

Closed
arronKler wants to merge 2 commits into
pytest-dev:mainfrom
arronKler:fix/13319-collection-parent-sub
Closed

Collect sibling tests when parent and subfolder are both given#14878
arronKler wants to merge 2 commits into
pytest-dev:mainfrom
arronKler:fix/13319-collection-parent-sub

Conversation

@arronKler

@arronKler arronKler commented Aug 14, 2026

Copy link
Copy Markdown

Passing both a parent directory and one of its subfolders collected only the named subfolder:

pytest --collect-only -q parent/sub1 parent/

expected every test under parent/, but only parent/sub1 ran.

Collection arguments are already normalized so a parent path replaces an overlapping child (normalize_collection_arguments, added for #12083 / #13704). This keeps that behavior covered for the layout in #13319: tests only in sibling subfolders, none in the parent directory itself, including a trailing slash on the parent.

Fixes #13319

Specifying both a parent directory and one of its subfolders must
collect sibling folders too, not only the named child. Cover the
pytest-dev#13319 layout (tests only under subfolders) and unit-test that
normalization keeps the parent path.

Fixes pytest-dev#13319
@psf-chronographer psf-chronographer Bot added the bot:chronographer:provided (automation) changelog entry is part of PR label Aug 14, 2026
@arronKler

Copy link
Copy Markdown
Author

Closing this as superseded: collection of parent+child paths is already handled on main by normalize_collection_arguments (#12083 / #13704). This PR was tests-only and should not stay open as a product fix.

@arronKler arronKler closed this Aug 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bot:chronographer:provided (automation) changelog entry is part of PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Collection Incorrect When Specify Both Parent and Sub Folders

1 participant