# E       fixture 'db_connection' not found

- **ID:** `python/pytest-collection-fixture-not-found`
- **Domain:** python
- **Category:** config_error
- **Verification:** ai_generated
- **Fix Rate:** 80%

## Root Cause

pytest cannot locate a fixture referenced by a test. The fixture is either defined in a conftest.py outside the test's rootdir, misspelled, not imported, or scoped to a directory pytest isn't collecting.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| 7.x | active | — | — |
| 8.x | active | — | — |

## Workarounds

1. **** (92% success)
   ```
   # conftest.py at project root
import pytest
@pytest.fixture
def db_connection():
    conn = create_conn()
    yield conn
    conn.close()

# tests/test_x.py
def test_query(db_connection):
    assert db_connection.execute('SELECT 1').fetchone()
   ```
2. **** (85% success)
   ```
   # tests/conftest.py
pytest_plugins = ['myapp.testing.fixtures']

# run with explicit rootdir
# pytest --rootdir=. tests/
   ```
3. **** (78% success)
   ```
   pytest --fixtures -q | grep db_connection
# If missing, check conftest.py location and rootdir:
pytest --collect-only -q
   ```

## Dead Ends

- **** — Duplicates fixture logic across files, and if the fixture depends on session-scoped resources (DB, network), local copies break isolation and teardown. (60% fail)
- **** — PYTHONPATH affects import resolution, not pytest fixture discovery. conftest.py is discovered by walking up from rootdir, not via sys.path. (75% fail)
