# ValueError: parametrize 中的 'test_id' 重复

- **ID:** `python/pytest-parametrize-id-conflict`
- **领域:** python
- **类别:** data_error
- **验证级别:** ai_generated
- **修复率:** 80%

## 根因

两个或多个参数化测试用例具有相同的 ID，可能是通过 ids 参数显式设置，或从相同的参数值自动生成。

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| 7.x | active | — | — |
| 8.x | active | — | — |

## 解决方案

1. **** (95% 成功率)
   ```
   @pytest.mark.parametrize('x,y', [(1,2), (1,2)], ids=['case1', 'case2'])
def test_add(x, y):
    assert x + y == 3
   ```
2. **** (90% 成功率)
   ```
   @pytest.mark.parametrize('x,y,case', [(1,2,'a'), (1,2,'b')])
def test_add(x, y, case):
    assert x + y == 3
   ```

## 无效尝试

- **** — pytest will still generate duplicate IDs if the parameter values are identical, causing the same error. (75% 失败率)
- **** — The conflict is in the parametrize IDs, not the test function name. Renaming the function does not resolve the duplicate ID. (90% 失败率)
