# AttributeError: 'dict' object has no attribute 'items'

- **ID:** `python/pytest-mock-patch-dict`
- **Domain:** python
- **Category:** type_error
- **Verification:** ai_generated
- **Fix Rate:** 80%

## Root Cause

A dictionary was patched with a Mock, but the code expects a real dictionary and calls dict methods like .items().

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| 3.x | active | — | — |

## Workarounds

1. **** (95% success)
   ```
   patch.dict('module.my_dict', {'key': 'value'}) or use a simple class that implements the required methods.
   ```
2. **** (85% success)
   ```
   mock_dict = Mock()
mock_dict.items.return_value = [('key', 'value')]
patch('module.my_dict', mock_dict)
   ```

## Dead Ends

- **** — MagicMock supports magic methods but not dict-specific methods like .items() unless configured. (70% fail)
- **** — This defeats the purpose of the test and may cause other failures. (90% fail)
