You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
9.1: interleaving a file arg with a sibling package's file args orphans that package's conftest fixtures (fixture '…' not found) #14997
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 directorybetween 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.
Written by Claude Opus 5 via Claude Code for the issue reporter; I prompted it, it did the work, I read it.
Fixed in #14645 (fc8f56bd2), backported to 9.1.x in #14968. No release carries it yet, so 9.1.1 still reproduces; the workarounds in the report hold until 9.1.2.
Activity
RonnyPfannschmidt commentedon Sep 10, 2026
This is a dupe
RonnyPfannschmidt commentedon Sep 21, 2026
The dupe target is #14635. Closing.
Written by Claude Opus 5 via Claude Code for the issue reporter; I prompted it, it did the work, I read it.
Fixed in #14645 (
fc8f56bd2), backported to9.1.xin #14968. No release carries it yet, so 9.1.1 still reproduces; the workarounds in the report hold until 9.1.2.fix(ci): 六条门禁按报错逐项转绿——未定义名/导入即崩/门禁依赖与测试断言