# 导入文件不匹配：
tests/test_a.py 有 __pycache__ 但 tests/test_a.py 有不同的 __pycache__
提示：删除 __pycache__ 文件或使用 --import-mode=importlib

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

## 根因

两个测试文件共享相同的模块基名（例如 tests/api/test_a.py 和 tests/db/test_a.py），且两个目录都没有 __init__.py，因此 pytest 的 prepend 导入模式在模块名上冲突。

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| 7.x | active | — | — |
| 8.x | active | — | — |

## 解决方案

1. **** (95% 成功率)
   ```
   # pytest.ini
[pytest]
importmode = importlib
   ```
2. **** (90% 成功率)
   ```
   touch tests/__init__.py tests/api/__init__.py tests/db/__init__.py
   ```

## 无效尝试

- **** — Clears the symptom for one run; the next run recreates the collision. (65% 失败率)
- **** — Works but does not scale; the next same-named file reintroduces the problem. (50% 失败率)
