# AttributeError: module 'unittest' has no attribute 'mock'

- **ID:** `python/unittest-mock-no-attribute`
- **Domain:** python
- **Category:** module_error
- **Verification:** ai_generated
- **Fix Rate:** 80%

## Root Cause

`unittest.mock` is a submodule that must be imported explicitly. Writing `import unittest` then `unittest.mock.patch(...)` fails because the submodule isn't loaded until imported.

## Version Compatibility

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

## Workarounds

1. **** (98% success)
   ```
   Import the submodule explicitly:
from unittest import mock
# or
import unittest.mock

with mock.patch('mymodule.requests.get') as m:
    ...
   ```

## Dead Ends

- **** — mock has been a submodule since 3.3; version is not the problem, import style is. (80% fail)
- **** — Installing the backport doesn't bind `unittest.mock`; the attribute error persists. (65% fail)
