# 断言错误：断言 [1, 2, 3] == [1, 2, 4]

- **ID:** `python/assertionerror-assert-equal-lists`
- **领域:** python
- **类别:** runtime_error
- **验证级别:** ai_generated
- **修复率:** 80%

## 根因

列表逐元素比较；一个元素不匹配导致整个断言失败。

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| 3.8 | active | — | — |
| 3.9 | active | — | — |
| 3.10 | active | — | — |

## 解决方案

1. **Use assertListEqual for detailed diff output** (95% 成功率)
   ```
   self.assertListEqual([1, 2, 3], [1, 2, 4])
   ```
2. **Convert to tuples before comparison** (85% 成功率)
   ```
   assert tuple([1, 2, 3]) == tuple([1, 2, 4])
   ```

## 无效尝试

- **Using assertEqual without understanding deep comparison** — assertEqual uses == which compares references for mutable objects; may not catch structural differences. (60% 失败率)
- **Manually iterating and comparing each element** — Redundant and error-prone; often misses edge cases like empty lists or type mismatches. (40% 失败率)
