# AttributeError: 'module' object has no attribute 'some_func'

- **ID:** `python/pytest-monkeypatch-attribute-not-exist`
- **Domain:** python
- **Category:** runtime_error
- **Verification:** ai_generated
- **Fix Rate:** 80%

## Root Cause

使用 monkeypatch 尝试修补不存在的属性，通常因为拼写错误或模块路径错误。

## Version Compatibility

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

## Workarounds

1. **使用正确的完整路径** (90% success)
   ```
   monkeypatch.setattr('module.submodule.func', lambda: 42)
   ```
2. **先导入模块对象再修补** (95% success)
   ```
   import module
monkeypatch.setattr(module, 'func', lambda: 42)
   ```

## Dead Ends

- **使用 setattr 而不是 monkeypatch.setattr** — 尝试使用 setattr 直接设置属性，但 monkeypatch 的上下文管理器自动恢复会失败 (50% fail)
- **修补错误的模块路径** — 尝试修补模块的 __init__.py 中的函数，但实际函数定义在子模块中 (60% fail)
