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

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

## Root Cause

The mock was applied to the wrong namespace or the code under test imports the function directly, bypassing the patch.

## Version Compatibility

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

## Workarounds

1. **** (95% success)
   ```
   If my_module.py does 'from other_module import my_func', patch 'my_module.my_func' instead of 'other_module.my_func'.
   ```
2. **** (90% success)
   ```
   def test_my_func(monkeypatch):
    monkeypatch.setattr('my_module.my_func', lambda: None)
    # test code
   ```
3. **** (85% success)
   ```
   import my_module; print(my_module.my_func.__module__) to see where it's defined, then patch accordingly.
   ```

## Dead Ends

- **** — The test then passes but does not verify the intended behavior; the mock is still not applied. (95% fail)
- **** — If the target is incorrect, patch.object fails similarly. (90% fail)
