# AssertionError: ValueError not raised

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

## Root Cause

The code under test does not raise the expected exception, or the exception is caught inside the function, or the test is not actually executing the code that should raise.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| 3.8 | active | — | — |
| 3.12 | active | — | — |

## Workarounds

1. **** (85% success)
   ```
   Add print statements before the call to ensure it's reached. Use pdb.set_trace() to step through. Check if the function has a try/except that swallows the error.
   ```
2. **** (90% success)
   ```
   with self.assertRaises(ValueError) as cm:
    my_func()
print(cm.exception)  # see if any exception was raised
   ```

## Dead Ends

- **** — This duplicates assertRaises and often leads to false positives if the exception is caught. (90% fail)
- **** — The underlying issue is that the exception is not raised, so switching frameworks won't help. (95% fail)
