python install_error ai_generated true

fixture 'benchmark' not found

ID: python/pytest-benchmark-no-fixture

Also available as: JSON · Markdown · 中文
80%Fix Rate
87%Confidence
0Evidence
2024-06-07First Seen

Version Compatibility

VersionStatusIntroducedDeprecatedNotes
4.x active

Root Cause

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

中文

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

Workarounds

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

Dead Ends

Common approaches that don't work:

  1. 90% fail

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

  2. 75% fail

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