# no tests ran in 0.12s
ERROR: 文件或目录未找到: tests/test_api.py

- **ID:** `python/pytest-exit-code-5-no-tests-collected`
- **领域:** python
- **类别:** config_error
- **验证级别:** ai_generated
- **修复率:** 80%

## 根因

传给 pytest 的路径相对于当前工作目录不存在，或测试文件被重命名/移动。当未收集到测试时，pytest 以代码 5（EXIT_NOTESTSCOLLECTED）退出。

## 版本兼容性

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

## 解决方案

1. **** (92% 成功率)
   ```
   cd /app && pytest
   ```
2. **** (88% 成功率)
   ```
   test -f tests/test_api.py && pytest tests/test_api.py || echo 'missing test file'
   ```

## 无效尝试

- **** — Ignoring the directory means the intended tests never run; the CI job passes green while testing nothing. (90% 失败率)
- **** — Masks genuinely missing tests and broken collection, allowing regressions through. (85% 失败率)
