Title: 9.1: interleaving a file arg with a sibling package's file args orphans that package's conftest fixtures (fixture '…' not found)
Environment: pytest 9.1.1, CPython 3.12, Windows 11. (Believed introduced by the pytest-9 conftest/fixture rework that binds fixtures onto the collector node object and matches by node identity; the pre-9 string-baseid matching would have masked it.)
What happens
When the command line lists a test file that sits directly under a directory between files that live under a subpackage of that same directory, the subpackage's conftest.py fixtures become invisible for the run — every test needing one errors out with fixture '<name>' not found, even though the fixture is defined and the same files pass in isolation or when the args are reordered.
Minimal reproducer
Layout:
tests/
conftest.py # (empty is fine)
test_top.py # a file directly under tests/, no special fixtures
pkg/
conftest.py # defines: @pytest.fixture\n def widget(): return 1
test_a.py # def test_a(widget): assert widget == 1
test_b.py # def test_b(widget): assert widget == 1
# FAILS — errors: fixture 'widget' not found (for test_b, the pkg arg AFTER test_top.py)
$ pytest tests/pkg/test_a.py tests/test_top.py tests/pkg/test_b.py
# PASSES — same files, the top-level file listed FIRST
$ pytest tests/test_top.py tests/pkg/test_a.py tests/pkg/test_b.py
# PASSES — directory arg
$ pytest tests/
Expected
Interleaving a directly-named file with a sibling package's file args should not change fixture resolution; the package's conftest.py fixtures should resolve regardless of arg order (as they do for a directory arg).
Workarounds (for other users hitting this)
- Pass directories (
pytest tests/), or
- List any file directly under a package before that package's subdirectory files.
Title: 9.1: interleaving a file arg with a sibling package's file args orphans that package's conftest fixtures (
fixture '…' not found)Environment: pytest 9.1.1, CPython 3.12, Windows 11. (Believed introduced by the pytest-9 conftest/fixture rework that binds fixtures onto the collector node object and matches by node identity; the pre-9 string-baseid matching would have masked it.)
What happens
When the command line lists a test file that sits directly under a directory between files that live under a subpackage of that same directory, the subpackage's
conftest.pyfixtures become invisible for the run — every test needing one errors out withfixture '<name>' not found, even though the fixture is defined and the same files pass in isolation or when the args are reordered.Minimal reproducer
Layout:
Expected
Interleaving a directly-named file with a sibling package's file args should not change fixture resolution; the package's
conftest.pyfixtures should resolve regardless of arg order (as they do for a directory arg).Workarounds (for other users hitting this)
pytest tests/), or