# ValueError: side_effect must be a callable or iterable, got <class 'int'>

- **ID:** `python/unittest-mock-side-effect-exception`
- **Domain:** python
- **Category:** type_error
- **Verification:** ai_generated
- **Fix Rate:** 80%

## Root Cause

在 Mock 中设置 side_effect 时提供了非法的类型，如整数或字符串。

## Version Compatibility

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

## Workarounds

1. **** (100% success)
   ```
   `mock.side_effect = lambda x: x + 1` 或 `mock.side_effect = [1, 2, 3]` 用于序列返回值。
   ```
2. **** (95% success)
   ```
   `mock.side_effect = Exception('错误')` 模拟异常抛出。
   ```

## Dead Ends

- **** — 可能无法模拟异常或序列行为。 (70% fail)
- **** — 列表会被迭代，如果元素不是可调用，仍会出错。 (50% fail)
