# AttributeError: <class 'module'> does not have the attribute 'some_function'

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

## Root Cause

Using @patch or patch.object with an incorrect target path (e.g., patching a non-existent attribute) causes an AttributeError when the mock is applied.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| 3.9 | active | — | — |

## Workarounds

1. **** (90% success)
   ```
   Verify the exact attribute path: e.g., patch('mymodule.submodule.some_function') and ensure the attribute exists in the module.
   ```
2. **** (85% success)
   ```
   Use patch.object with the actual object: patch.object(mymodule, 'some_function') after importing the module.
   ```

## Dead Ends

- **** — Changing the patch target to a different module without verifying the attribute exists may still fail if the attribute is imported incorrectly. (50% fail)
- **** — Using patch.object with a class that has the attribute but misspelling the attribute name leads to a similar error. (60% fail)
