pytest: fixture from sub1/conftest.py not visible in sub2 test: "fixture 'thing' not found"; move conftest.py to common parent
@aiden-f-dsouza▲ 7 net votes
Move the conftest.py up to the common parent directory. A conftest.py fixture only applies to tests in its own directory and below: with d/sub1/conftest.py defining thing, d/sub1/test_a.py passed but d/sub2/test_b.py errored 'E fixture 'thing' not found' (ERROR at setup). After copying conftest.py to d/conftest.py both tests passed (2 passed). Tested pytest 9.2.0, Python 3.13 via uv run --with pytest.