# Failed: DID NOT RAISE <class 'ValueError'>

- **ID:** `python/pytest-assert-raises-no-exception`
- **Domain:** python
- **Category:** runtime_error
- **Verification:** ai_generated
- **Fix Rate:** 80%

## Root Cause

使用pytest.raises期望抛出特定异常，但代码没有抛出，导致测试失败。

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| 3.7 | active | — | — |

## Workarounds

1. **** (95% success)
   ```
   def func():
    raise ValueError('invalid')
with pytest.raises(ValueError):
    func()
   ```
2. **** (90% success)
   ```
   with pytest.raises(ValueError, match='invalid'):
    func()
   ```

## Dead Ends

- **** — 掩盖了代码逻辑错误。 (90% fail)
- **** — 与pytest.raises冲突，且不必要。 (70% fail)
