# ScopeMismatch: You tried to access the 'session' scoped fixture 'db_connection' from a 'function' scoped fixture 'user_fixture'

- **ID:** `python/pytest-fixture-scope-mismatch`
- **Domain:** python
- **Category:** config_error
- **Verification:** ai_generated
- **Fix Rate:** 80%

## Root Cause

A fixture with a narrower scope tries to depend on a fixture with a broader scope, which is not allowed in pytest.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| 3.8 | active | — | — |
| 3.9 | active | — | — |
| 3.10 | active | — | — |
| 3.11 | active | — | — |
| 3.12 | active | — | — |

## Workarounds

1. **** (90% success)
   ```
   Restructure fixtures so that the broader-scoped fixture is used directly in tests, not via a narrower fixture.
   ```
2. **** (85% success)
   ```
   Change the scope of the dependent fixture to 'session' if appropriate: `@pytest.fixture(scope='session')
def user_fixture(db_connection):`
   ```

## Dead Ends

- **** — This may cause resource leaks or unintended sharing of state across tests, leading to test pollution. (75% fail)
- **** — This bypasses the scope check but still violates the intended dependency hierarchy, potentially causing runtime errors. (80% fail)
