# AttributeError: Mock object has no attribute 'close'
During handling of the above exception, another exception occurred:
TypeError: object MagicMock can't be used in 'await' expression

- **ID:** `python/pytest-mock-magicmock-spec-missing`
- **Domain:** python
- **Category:** type_error
- **Verification:** ai_generated
- **Fix Rate:** 80%

## Root Cause

A MagicMock was returned where an async context manager or specific interface was expected. MagicMock auto-creates attributes but its return values are not awaitable; use AsyncMock for coroutines and configure magic methods.

## Version Compatibility

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

## Workarounds

1. **** (93% success)
   ```
   Use AsyncMock for async interfaces:
  from unittest.mock import AsyncMock
  mock_client = AsyncMock()
  mock_client.get.return_value = {'ok': True}
   ```
2. **** (85% success)
   ```
   Configure magic methods on MagicMock:
  m = MagicMock()
  m.__aenter__ = AsyncMock(return_value=m)
  m.__aexit__ = AsyncMock(return_value=None)
   ```

## Dead Ends

- **** — Fixes only the first error; await-related TypeError persists for async usage. (70% fail)
- **** — Plain Mock does not support __aenter__/__aexit__ or magic methods; more AttributeErrors appear. (85% fail)
