python
config_error
ai_generated
true
收集到 0 项 / 1 个错误 错误:未找到 /proj/tests/test_math.py::test_add 的收集器
collected 0 items / 1 error ERROR: found no collectors for /proj/tests/test_math.py::test_add
ID: python/pytest-collection-zero-tests
80%修复率
90%置信度
0证据数
2024-02-14首次发现
版本兼容性
| 版本 | 状态 | 引入 | 弃用 | 备注 |
|---|---|---|---|---|
| 7.x | active | — | — | — |
| 8.x | active | — | — | — |
根因分析
测试文件或类不匹配 pytest 的默认发现模式(test_*.py / *_test.py、Test* 类、test_* 函数),或语法/导入错误阻止了收集。
English
The test file or class does not match pytest's default discovery pattern (test_*.py / *_test.py, Test* class, test_* function), or a syntax/import error prevented collection.
解决方案
-
95% 成功率
mv tests/math_test.py tests/test_math.py # class CheckMath -> class TestMath # def check_add -> def test_add
-
90% 成功率
# pytest.ini [pytest] python_files = *_test.py test_*.py python_classes = Check* Test* python_functions = check_* test_*
-
88% 成功率
pytest --collect-only -q -vv tests/test_math.py
无效尝试
常见但无效的做法:
-
95% 失败
Cache provider has nothing to do with discovery patterns.
-
90% 失败
There are no failures; there are no tests collected.
-
90% 失败
Coverage plugin doesn't affect collection rules.