# AssertionError: ValueError not raised when calling func()

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

## Root Cause

The test uses assertRaises but the code under test does not raise the expected exception, either due to a bug in the code or incorrect test setup.

## Version Compatibility

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

## Workarounds

1. **** (85% success)
   ```
   Debug the code under test to ensure it raises the exception under the given conditions. For example, check input validation logic.
   ```
2. **** (90% success)
   ```
   Use assertRaises with a lambda or callable: self.assertRaises(ValueError, func, arg) to ensure the exception is raised during the call.
   ```

## Dead Ends

- **** — Wrapping the call in a try-except block and manually asserting may mask other issues like incorrect exception types. (60% fail)
- **** — Changing the expected exception to a broader type (e.g., Exception) works but reduces test specificity and may hide bugs. (40% fail)
