# ERROR: 找不到文件或目录: tests/conftest.py

0.001s 内未运行测试

- **ID:** `python/pytest-conftest-not-collected`
- **领域:** python
- **类别:** config_error
- **验证级别:** ai_generated
- **修复率:** 80%

## 根因

conftest.py 是配置文件而非测试模块；pytest 不从其中收集测试。显式在命令行传入它会产生此错误。

## 版本兼容性

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

## 解决方案

1. **** (97% 成功率)
   ```
   Run the test directory or a specific test, not conftest.py:
pytest tests/
# or
pytest tests/test_api.py::test_health
   ```
2. **** (85% 成功率)
   ```
   If you want to test fixture logic, move helpers to a module and import them:
# tests/helpers.py
def make_client(): ...
# tests/test_helpers.py
from tests.helpers import make_client
   ```

## 无效尝试

- **** — Fixtures defined there are no longer auto-discovered by sibling tests; they break. (90% 失败率)
- **** — pytest still ignores tests in conftest.py; behavior is undefined and confusing. (85% 失败率)
