# 收集到 0 项 / 1 个错误

错误：未找到 /proj/tests/test_math.py::test_add 的收集器

- **ID:** `python/pytest-collection-zero-tests`
- **领域:** python
- **类别:** config_error
- **验证级别:** ai_generated
- **修复率:** 80%

## 根因

测试文件或类不匹配 pytest 的默认发现模式（test_*.py / *_test.py、Test* 类、test_* 函数），或语法/导入错误阻止了收集。

## 版本兼容性

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

## 解决方案

1. **** (95% 成功率)
   ```
   mv tests/math_test.py tests/test_math.py
# class CheckMath -> class TestMath
# def check_add -> def test_add
   ```
2. **** (90% 成功率)
   ```
   # pytest.ini
[pytest]
python_files = *_test.py test_*.py
python_classes = Check* Test*
python_functions = check_* test_*
   ```
3. **** (88% 成功率)
   ```
   pytest --collect-only -q -vv tests/test_math.py
   ```

## 无效尝试

- **** — Cache provider has nothing to do with discovery patterns. (95% 失败率)
- **** — There are no failures; there are no tests collected. (90% 失败率)
- **** — Coverage plugin doesn't affect collection rules. (90% 失败率)
