# AssertionError: Expected 'send_email' to have been called once. Called 0 times.

- **ID:** `python/pytest-mock-not-called`
- **Domain:** python
- **Category:** runtime_error
- **Verification:** ai_generated
- **Fix Rate:** 80%

## Root Cause

The mocked function was not called because the code under test uses a different reference (e.g., imported directly) or the test logic does not reach the call.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| 3.8 | active | — | — |
| 3.12 | active | — | — |

## Workarounds

1. **** (95% success)
   ```
   If myapp/service.py has 'from myapp.utils import send_email', patch 'myapp.service.send_email'.
If it has 'import myapp.utils', patch 'myapp.utils.send_email'.
   ```
2. **** (90% success)
   ```
   Add a print before the call in the source code, or use pdb to step through.
   ```

## Dead Ends

- **** — The patch must target where the function is looked up, not where it's defined. (85% fail)
- **** — May not work if the code uses a module-level import. (80% fail)
