# TypeError: cannot mock attribute 'requests' of 'module' object; use patch.object() instead

- **ID:** `python/unittest-mock-patch-import-order`
- **Domain:** python
- **Category:** config_error
- **Verification:** ai_generated
- **Fix Rate:** 80%

## Root Cause

Using @patch('module.requests') when 'requests' is a module-level import and not an attribute of the module object, often due to import order or namespace issues.

## Version Compatibility

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

## Workarounds

1. **** (90% success)
   ```
   Use patch.object(module, 'requests') to mock the attribute directly on the module object.
   ```
2. **** (85% success)
   ```
   Patch the module where it is used: e.g., patch('module.requests.get') if you want to mock a specific method.
   ```

## Dead Ends

- **** — Changing the import to 'from module import requests' and patching 'module.requests' may still fail if the import is inside a function. (50% fail)
- **** — Using patch('requests') instead of 'module.requests' patches the global requests module, which may affect other tests. (60% fail)
