From 9a050684f7384ca1ba0efe969e9fa67a6ad4980a Mon Sep 17 00:00:00 2001 From: skshetry <18718008+skshetry@users.noreply.github.com> Date: Mon, 11 Nov 2024 17:54:08 +0545 Subject: [PATCH] fix issue with pytest-benchmark==5 (#10618) --- dvc/testing/benchmarks/fixtures.py | 5 +++-- dvc/testing/benchmarks/plugin.py | 2 +- pyproject.toml | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/dvc/testing/benchmarks/fixtures.py b/dvc/testing/benchmarks/fixtures.py index b8ebcedb87..c6f981f527 100644 --- a/dvc/testing/benchmarks/fixtures.py +++ b/dvc/testing/benchmarks/fixtures.py @@ -150,7 +150,8 @@ def _make_bench(name): import pytest_benchmark.plugin # hack from https://github.com/ionelmc/pytest-benchmark/issues/166 - bench = pytest_benchmark.plugin.benchmark.__pytest_wrapped__.obj(request) + bench_gen = pytest_benchmark.plugin.benchmark.__pytest_wrapped__.obj(request) + bench = next(bench_gen) suffix = f"-{name}" @@ -172,7 +173,7 @@ def _bench_dvc(*args, **kwargs): name = kwargs.pop("name", None) name = f"-{name}" if name else "" bench = make_bench(args[0] + name) - if request.config.getoption("--benchmark-cprofile-dump") or kwargs.pop( + if request.config.getoption("--dvc-benchmark-cprofile-dump") or kwargs.pop( "cprofile", False ): cprofile_results = request.config.invocation_params.dir / "prof" diff --git a/dvc/testing/benchmarks/plugin.py b/dvc/testing/benchmarks/plugin.py index 34ae45bd31..e4d7429003 100644 --- a/dvc/testing/benchmarks/plugin.py +++ b/dvc/testing/benchmarks/plugin.py @@ -73,7 +73,7 @@ def pytest_addoption(parser): ) parser.addoption( - "--benchmark-cprofile-dump", + "--dvc-benchmark-cprofile-dump", action="store_true", default=False, help="Save cprofile results", diff --git a/pyproject.toml b/pyproject.toml index 7bc860c085..903c7f577a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -99,7 +99,7 @@ s3 = ["dvc-s3>=3.2.0,<4"] ssh = ["dvc-ssh>=4,<5"] ssh_gssapi = ["dvc-ssh[gssapi]>=4,<5"] testing = [ - "pytest-benchmark[histogram]", + "pytest-benchmark[histogram]>=5,<6", "pytest-test-utils", "uv", ]