# AssertionError: ValueError not raised by my_function

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

## Root Cause

The function under test does not raise the expected exception, or the exception is caught inside the function and not re-raised.

## Version Compatibility

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

## Workarounds

1. **** (95% success)
   ```
   def my_function(x):
    if x < 0:
        raise ValueError('negative')
    return x

with self.assertRaises(ValueError):
    my_function(-1)
   ```
2. **** (90% success)
   ```
   with pytest.raises(ValueError, match='negative'):
    my_function(-1)
   ```

## Dead Ends

- **** — Tests the test, not the function; false positive. (95% fail)
- **** — Too broad; may pass for unrelated exceptions and hide bugs. (70% fail)
