# AttributeError: <module 'myapp' from '...'> does not have attribute 'config'

- **ID:** `python/unittest-mock-patch-object-attribute`
- **Domain:** python
- **Category:** attribute_error
- **Verification:** ai_generated
- **Fix Rate:** 80%

## Root Cause

在 patch.object 中指定了不存在的属性，或模块被错误导入。

## Version Compatibility

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

## Workarounds

1. **** (90% success)
   ```
   在测试前 `hasattr(myapp, 'config')`，确保存在再 patch。
   ```
2. **** (85% success)
   ```
   `patch('myapp.config')` 如果属性在模块级别。
   ```

## Dead Ends

- **** — 修改生产代码，且可能不需要。 (70% fail)
- **** — patch 需要字符串路径，可能同样出错。 (60% fail)
