# AttributeError: <class 'myapp.models.User'> does not have the attribute 'save'

- **ID:** `python/unittest-mock-patch-object-not-found`
- **Domain:** python
- **Category:** runtime_error
- **Verification:** ai_generated
- **Fix Rate:** 80%

## Root Cause

patch.object is used to patch an attribute that does not exist on the target object. This can happen if the method is inherited or defined dynamically.

## Version Compatibility

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

## Workarounds

1. **** (90% success)
   ```
   with patch.object(User, 'save', create=True) as mock_save:
    ...
   ```
2. **** (85% success)
   ```
   If save is inherited from BaseModel, patch that: patch.object(BaseModel, 'save')
   ```

## Dead Ends

- **** — patch also requires the attribute to exist unless create=True is used. (70% fail)
- **** — This changes production code to satisfy a test, which is not ideal. (80% fail)
