# AttributeError: Mock object has no attribute 'return_value' when setting return_value on a non-callable mock

- **ID:** `python/unittest-mock-return-value-override`
- **Domain:** python
- **Category:** type_error
- **Verification:** ai_generated
- **Fix Rate:** 80%

## Root Cause

Attempting to set return_value on a Mock instance that was created with spec=None and not as a callable, but the mock is being used as if it were a function.

## Version Compatibility

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

## Workarounds

1. **Ensure the mock is created as a callable by using MagicMock or by passing spec=SomeCallable** (90% success)
   ```
   from unittest.mock import MagicMock
mock = MagicMock()
mock.return_value = 42
result = mock()  # Works
Or: mock = Mock(spec=lambda: None)
mock.return_value = 42
   ```
2. **Use side_effect instead of return_value for non-callable mocks** (0% success)

## Dead Ends

- **Creating a new MagicMock instead of Mock** — MagicMock is callable by default, but the underlying issue may be that the mock is not intended to be callable. (50% fail)
- **Setting return_value directly without checking if the mock is callable** — This will still raise an AttributeError if the mock is not callable. (70% fail)
