# AttributeError: <module 'module_name' from '/path/to/module.py'> does not have the attribute 'function_name'

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

## Root Cause

Mock patch target is incorrect; patching the module path instead of the location where the function is used.

## Version Compatibility

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

## Workarounds

1. **** (95% success)
   ```
   @patch('module_where_used.function_name')
def test_something(mock_func):
    ...
   ```
2. **** (90% success)
   ```
   @patch('module_name.function_name', create=True)
   ```

## Dead Ends

- **** — If the function is imported into another module, patching the original module doesn't affect the imported reference. (80% fail)
- **** — patch.object requires an existing attribute; if the attribute doesn't exist, it raises AttributeError. (70% fail)
