python install_error ai_generated true

未找到夹具 'benchmark'

fixture 'benchmark' not found

ID: python/pytest-benchmark-no-fixture

其他格式: JSON · Markdown 中文 · English
80%修复率
87%置信度
0证据数
2024-06-07首次发现

版本兼容性

版本状态引入弃用备注
4.x active

根因分析

pytest-benchmark 插件未安装或未加载,因此 benchmark 夹具不可用。如果插件在 pytest.ini 中被禁用,也可能发生这种情况。

English

pytest-benchmark plugin is not installed or not loaded, so the benchmark fixture is unavailable. This can also happen if the plugin is disabled in pytest.ini.

generic

解决方案

  1. 95% 成功率
    pip install pytest-benchmark
    pytest --benchmark-only
  2. 90% 成功率
    # pytest.ini
    [pytest]
    # Remove -p no:benchmark if present
    addopts = -p benchmark

无效尝试

常见但无效的做法:

  1. 90% 失败

    This shadows the plugin's fixture and does not provide benchmarking functionality. The test will not actually benchmark anything.

  2. 75% 失败

    This provides raw timing but lacks statistical analysis, warmup, and comparison features of pytest-benchmark.