# AssertionError: Exception not raised

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

## Root Cause

A test expects an exception to be raised using pytest.raises or assertRaises, but the code executes without exception.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| 3.8 | active | — | — |
| 3.9 | active | — | — |
| 3.10 | active | — | — |

## Workarounds

1. **Use pytest.raises with exact exception** (95% success)
   ```
   with pytest.raises(ValueError):
    raise ValueError('test')
   ```
2. **Use unittest.TestCase.assertRaises** (90% success)
   ```
   self.assertRaises(ValueError, func, arg)
   ```

## Dead Ends

- **Adding a try-except block manually** — Manual try-except may miss the exact exception type or not fail properly. (60% fail)
- **Using a broader exception type** — Catches unintended exceptions and may hide bugs. (50% fail)
