# ScopeMismatch: You tried to access the function scoped fixture 'tmp_path' with a session scoped request object

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

## Root Cause

A higher-scoped fixture (session/module) depends on a lower-scoped fixture (function), which pytest forbids because the lower-scoped fixture would need to be recreated per test.

## Version Compatibility

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

## Workarounds

1. **** (92% success)
   ```
   # Instead of session-scoped fixture depending on tmp_path:
@pytest.fixture
def db(tmp_path):
    ...

@pytest.fixture(scope="session")
def db_session():
    import tempfile
    with tempfile.TemporaryDirectory() as d:
        yield make_db(d)
   ```
2. **** (75% success)
   ```
   @pytest.fixture(scope="session")
def heavy(request):
    def get_tmp():
        return request.getfixturevalue("tmp_path")
    yield get_tmp
   ```

## Dead Ends

- **** — The error is raised by pytest during fixture resolution before the body runs; catching it inside the fixture never executes. (98% fail)
- **** — autouse changes when fixtures are requested, not their scope, so the ScopeMismatch persists. (90% fail)
- **** — No such option exists; pytest ignores unknown ini keys and the error remains. (95% fail)
