python
install_error
ai_generated
true
fixture 'benchmark' 未找到 可用 fixtures: cache, capfd, ...
fixture 'benchmark' not found available fixtures: cache, capfd, ...
ID: python/pytest-benchmark-not-found
80%修复率
88%置信度
0证据数
2025-02-24首次发现
版本兼容性
| 版本 | 状态 | 引入 | 弃用 | 备注 |
|---|---|---|---|---|
| 7.x | active | — | — | — |
| 8.x | active | — | — | — |
根因分析
未安装 pytest-benchmark,因此它提供的 'benchmark' fixture 不可用。常见于将 benchmark 测试复制到未安装开发依赖的仓库。
English
pytest-benchmark is not installed, so the 'benchmark' fixture it provides is unavailable. Common when copying benchmark tests into a repo without the dev dependency.
解决方案
-
97% 成功率
pip install pytest-benchmark # then def test_sort(benchmark): result = benchmark(sorted, list(range(1000))) assert result[0] == 0 -
90% 成功率
import pytest pytest.importorskip('pytest_benchmark') def test_sort(benchmark): benchmark(sorted, list(range(1000)))
无效尝试
常见但无效的做法:
-
90% 失败
Provides no timing, statistics, or comparison; the test gives false confidence.
-
70% 失败
No integration with pytest reporting, no --benchmark-compare, and noisy CI output.