# 0.00s 内没有运行任何测试
ERROR: 找不到文件或目录：tests/

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

## 根因

传给 pytest 的路径相对于当前工作目录不存在。常发生在 CI 中：工作目录是仓库根，但测试位于子包中，或者 Makefile 切换了目录。

## 版本兼容性

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

## 解决方案

1. **** (95% 成功率)
   ```
   Verify the path and use the full path:

pytest ./backend/tests
   ```
2. **** (95% 成功率)
   ```
   Set testpaths in config so pytest finds the right directory regardless of cwd:

# pyproject.toml
[tool.pytest.ini_options]
testpaths = ["backend/tests"]
   ```

## 无效尝试

- **** — May collect unrelated tests or fail to find anything if rootdir is misconfigured. (50% 失败率)
- **** — Silences the error but runs zero tests, causing CI to pass green with no coverage. (90% 失败率)
