Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Collection Incorrect When Specify Both Parent and Sub Folders #13319

Open
hfudev opened this issue Mar 21, 2025 · 0 comments
Open

Collection Incorrect When Specify Both Parent and Sub Folders #13319

hfudev opened this issue Mar 21, 2025 · 0 comments
Labels
topic: collection related to the collection phase type: bug problem that needs to be addressed

Comments

@hfudev
Copy link

hfudev commented Mar 21, 2025

Reproduce steps

# Create the main directory structure
mkdir -p test-pytest-collect/parent/sub1
mkdir -p test-pytest-collect/parent/sub2
mkdir -p test-pytest-collect/parent/sub3

# Create test files as one-liners
echo "def test_sub1(): pass" > test-pytest-collect/parent/sub1/test_sub1.py
echo "def test_sub2(): pass" > test-pytest-collect/parent/sub2/test_sub2.py
echo "def test_sub3(): pass" > test-pytest-collect/parent/sub3/test_sub3.py

go to test-pytest-collect folder, and install only pytest in venv


Expected

> pytest --collect-only -q
parent/sub1/test_sub1.py::test_sub1
parent/sub2/test_sub2.py::test_sub2
parent/sub3/test_sub3.py::test_sub3

3 tests collected in 0.00s

> pytest --collect-only -q parent/sub1
parent/sub1/test_sub1.py::test_sub1

1 test collected in 0.00s

Unexpected

> pytest --collect-only -q parent/sub1 parent/
parent/sub1/test_sub1.py::test_sub1

1 test collected in 0.00s
@Zac-HD Zac-HD added type: bug problem that needs to be addressed topic: collection related to the collection phase labels Mar 23, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
topic: collection related to the collection phase type: bug problem that needs to be addressed
Projects
None yet
Development

No branches or pull requests

2 participants