# 值错误：向 'test_add' 传递了 2 个参数，但预期 1 个

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

## 根因

@pytest.mark.parametrize 装饰器提供的参数数量与测试函数的参数列表不匹配，导致 ValueError。

## 版本兼容性

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

## 解决方案

1. **** (95% 成功率)
   ```
   Ensure the number of arguments in the parametrize decorator matches the test function's parameters. For example, if the test expects (a, b), use @pytest.mark.parametrize('a,b', [(1,2)])
   ```
2. **** (80% 成功率)
   ```
   Use a single argument with a tuple or list if the test function accepts one parameter that contains multiple values.
   ```

## 无效尝试

- **** — Adding extra parameters to the test function without updating the parametrize decorator may fix the count but could break other tests. (50% 失败率)
- **** — Removing arguments from the decorator without adjusting the test function leads to missing required parameters. (70% 失败率)
