# AssertionError: <class 'ValueError'> not raised

- **ID:** `python/unittest-assertraises-wrong-exception`
- **Domain:** python
- **Category:** runtime_error
- **Verification:** ai_generated
- **Fix Rate:** 80%

## Root Cause

The code under test did not raise the expected exception. This could be because the code path was not triggered, the exception type is different, or the code silently handles the error.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| 3.x | active | — | — |

## Workarounds

1. **** (92% success)
   ```
   with self.assertRaises(ValueError) as cm:
    my_function(invalid_input)
self.assertEqual(str(cm.exception), 'expected message')
   ```
2. **** (95% success)
   ```
   import pytest

with pytest.raises(ValueError, match='expected message'):
    my_function(invalid_input)
   ```

## Dead Ends

- **** — This broadens the assertion and may pass even when the wrong exception is raised, hiding bugs. (80% fail)
- **** — This bypasses assertRaises entirely and does not verify the exception type correctly. (85% fail)
