# AttributeError: Mock object has no attribute 'fetch_user'

- **ID:** `python/unittest-mock-autospec-missing`
- **Domain:** python
- **Category:** type_error
- **Verification:** ai_generated
- **Fix Rate:** 80%

## Root Cause

A plain MagicMock was used instead of create_autospec, so typos in method names are silently accepted until the mock is used as the real object and the attribute is looked up.

## Version Compatibility

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

## Workarounds

1. **** (95% success)
   ```
   from unittest.mock import create_autospec
mock_svc = create_autospec(UserService, instance=True)
# mock_svc.fetch_user now exists and typo'd names raise AttributeError
   ```
2. **** (90% success)
   ```
   from unittest.mock import Mock
mock_svc = Mock(spec=UserService)
   ```

## Dead Ends

- **** — Fixes one symptom but the mock still accepts any typo, so the next misspelling fails the same way. (70% fail)
- **** — Loses the ability to assert calls and may trigger real I/O or DB access. (75% fail)
