# ScopeMismatch: You tried to access the function scoped fixture mocker with a module scoped request object, involved factories:
module:  conftest.py:15: def module_mock(request)
function:  pytest_mock/plugin.py:40: def mocker()

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

## Root Cause

A module- or session-scoped fixture depends on a function-scoped fixture (mocker), which pytest forbids because the broader-scoped fixture outlives the narrower one.

## Version Compatibility

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

## Workarounds

1. **** (95% success)
   ```
   @pytest.fixture
def module_mock(mocker):  # function scope
    return mocker.patch('myapp.client')

# or use @pytest.fixture(scope='function')
   ```
2. **** (85% success)
   ```
   @pytest.fixture(scope='module')
def module_mock():
    from unittest.mock import patch
    with patch('myapp.client') as m:
        yield m
   ```

## Dead Ends

- **** — mocker is provided by pytest-mock and its scope is not configurable via pytest.ini; attempting to override it in conftest raises the same ScopeMismatch. (95% fail)
- **** — Decorator patching applies per-function, not per-module; it doesn't solve the need for a module-scoped mock and can conflict with other patches. (60% fail)
