# TypeError: unsupported operand type(s) for +: 'Mock' and 'int'

- **ID:** `python/unittest-mock-magic-method-not-supported`
- **Domain:** python
- **Category:** type_error
- **Verification:** ai_generated
- **Fix Rate:** 80%

## Root Cause

A plain unittest.mock.Mock does not implement magic methods like __add__, __len__, __iter__. Use MagicMock (or AsyncMock) when the code under test relies on dunder methods.

## Version Compatibility

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

## Workarounds

1. **** (98% success)
   ```
   from unittest.mock import MagicMock
m = MagicMock()
m.__add__.return_value = 42
assert m + 1 == 42
   ```
2. **** (90% success)
   ```
   from unittest.mock import AsyncMock
m = AsyncMock()
m.__aenter__.return_value = resource
   ```

## Dead Ends

- **** — Plain Mock ignores magic method assignments; you must use MagicMock for them to take effect. (90% fail)
- **** — int(Mock()) raises TypeError because Mock has no __int__; converting does not help. (95% fail)
