# ImportError: No module named 'module_to_patch'

- **ID:** `python/unittest-mock-patch-import-error`
- **Domain:** python
- **Category:** module_error
- **Verification:** ai_generated
- **Fix Rate:** 80%

## Root Cause

The `@unittest.mock.patch('module_to_patch.ClassName')` decorator tries to patch a module that does not exist or is not importable.

## Version Compatibility

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

## Workarounds

1. **** (95% success)
   ```
   Ensure the module path is correct: `@patch('my_package.module_to_patch.ClassName')`
   ```
2. **** (90% success)
   ```
   Use patch.object() with the actual class: `@patch.object(MyClass, 'method_name')`
   ```

## Dead Ends

- **** — The module might be an internal part of the codebase that should be patched differently. (60% fail)
- **** — Decorators are evaluated at import time; try-except cannot catch import errors in this context. (90% fail)
