# Failed: 没有引发 <class 'ValueError'>

- **ID:** `python/pytest-raises-missed-exception`
- **领域:** python
- **类别:** runtime_error
- **验证级别:** ai_generated
- **修复率:** 80%

## 根因

使用 pytest.raises(ValueError) 的测试期望引发异常，但代码执行时没有引发。

## 版本兼容性

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

## 解决方案

1. **** (90% 成功率)
   ```
   Check the code logic to ensure it raises ValueError under the given conditions, and fix if necessary.
   ```
2. **** (85% 成功率)
   ```
   Add debug prints to verify the input that should trigger the exception.
   ```

## 无效尝试

- **** — This defeats the purpose of the test; it should validate real error conditions. (95% 失败率)
- **** — This can mask other unexpected exceptions and reduce test effectiveness. (80% 失败率)
