# ImportError: 无法从 'conftest' 导入名称 'my_helper' (未知位置)

- **ID:** `python/pytest-conftest-import-error`
- **领域:** python
- **类别:** module_error
- **验证级别:** ai_generated
- **修复率:** 80%

## 根因

conftest.py 文件尝试导入一个未在其中定义的函数或变量，通常是由于循环导入或缺少定义。

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| 3.8 | active | — | — |
| 3.9 | active | — | — |
| 3.10 | active | — | — |
| 3.11 | active | — | — |
| 3.12 | active | — | — |

## 解决方案

1. **** (95% 成功率)
   ```
   Define the missing function in conftest.py or import it from a separate module: `from my_helpers import my_helper`
   ```
2. **** (90% 成功率)
   ```
   Check for circular imports by restructuring the code to avoid conftest importing itself.
   ```

## 无效尝试

- **** — The issue is not import order but the missing symbol; moving it does not help. (60% 失败率)
- **** — This changes the intended behavior and may cause other tests to fail. (80% 失败率)
