# AssertionError: ValueError not raised

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

## Root Cause

self.assertRaises(ValueError) was used as a context manager but the code under test did not raise, or the exception was caught and swallowed inside the function.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| 3.10 | active | — | — |
| 3.11 | active | — | — |
| 3.12 | active | — | — |

## Workarounds

1. **** (90% success)
   ```
   with self.assertRaises(ValueError) as ctx:
    parse('bad-input')
self.assertIn('bad-input', str(ctx.exception))
   ```
2. **** (92% success)
   ```
   import pytest

def test_parse_raises():
    with pytest.raises(ValueError, match=r'bad-input'):
        parse('bad-input')
   ```

## Dead Ends

- **** — Inverts the logic: except catches the expected exception and calls fail, so a correct raise now fails the test. (85% fail)
- **** — Broadens the assertion so much that any unrelated error (e.g. TypeError) passes the test, masking real bugs. (75% fail)
