# AssertionError: ValueError not raised
During handling of the above exception, another exception occurred:
TypeError: 'ValueError' object is not callable

- **ID:** `python/unittest-mock-side-effect-not-raised`
- **Domain:** python
- **Category:** type_error
- **Verification:** ai_generated
- **Fix Rate:** 80%

## Root Cause

mock.side_effect was set to an exception instance instead of the exception class; mock tries to call the instance and raises TypeError instead of the intended exception.

## Version Compatibility

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

## Workarounds

1. **** (96% success)
   ```
   from unittest import mock

with mock.patch('myapp.fetch') as m:
    m.side_effect = ValueError  # class, not ValueError()
    with pytest.raises(ValueError):
        call_sut()
   ```
2. **** (94% success)
   ```
   def boom(*args, **kwargs):
    raise ValueError('bad input')

with mock.patch('myapp.fetch', side_effect=boom):
    with pytest.raises(ValueError, match='bad input'):
        call_sut()
   ```

## Dead Ends

- **** — return_value returns the exception object as the call result; it is never raised, so the test still fails. (90% fail)
- **** — Masks the mock misconfiguration and makes the test pass for the wrong reason; the SUT never actually raised. (85% fail)
