Open
Description
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