diff --git a/dvc/testing/benchmarks/cli/commands/test_data_status.py b/dvc/testing/benchmarks/cli/commands/test_data_status.py index 49a9b76671..d2c73561ef 100644 --- a/dvc/testing/benchmarks/cli/commands/test_data_status.py +++ b/dvc/testing/benchmarks/cli/commands/test_data_status.py @@ -1,9 +1,5 @@ from shutil import rmtree -import pytest - -pytestmark = pytest.mark.requires(minversion=(2, 15, 0), reason="new command") - def test_data_status(bench_dvc, tmp_dir, scm, dvc, make_dataset): args = ("data", "status") diff --git a/dvc/testing/benchmarks/cli/commands/test_exp_show.py b/dvc/testing/benchmarks/cli/commands/test_exp_show.py index 2b1ace5098..0dad78ea43 100644 --- a/dvc/testing/benchmarks/cli/commands/test_exp_show.py +++ b/dvc/testing/benchmarks/cli/commands/test_exp_show.py @@ -1,7 +1,3 @@ -import pytest - - -@pytest.mark.requires(minversion=(2, 28, 0)) def test_exp_show(make_project, monkeypatch, bench_dvc, dvc_bin): url = "https://github.com/iterative/example-get-started" rev = "main" diff --git a/dvc/testing/benchmarks/cli/commands/test_import.py b/dvc/testing/benchmarks/cli/commands/test_import.py index f96295dd68..4884bed4b6 100644 --- a/dvc/testing/benchmarks/cli/commands/test_import.py +++ b/dvc/testing/benchmarks/cli/commands/test_import.py @@ -2,6 +2,12 @@ @pytest.mark.flaky(reruns=3) +@pytest.mark.requires( + "!=3.53.*,!=3.54.0", + reason="Takes 10 mins to run. Regression in 3.53.0, fixed in 3.54.1", +) +# Introduced in https://github.com/iterative/dvc/pull/10388. +# Fixed in https://github.com/iterative/dvc/pull/10531. def test_import(bench_dvc, tmp_dir, scm, dvc, make_dataset, remote): dataset = make_dataset( cache=False, files=False, dvcfile=True, commit=True, remote=True diff --git a/dvc/testing/benchmarks/cli/commands/test_plots.py b/dvc/testing/benchmarks/cli/commands/test_plots.py index 2ed3210dac..71a2f32414 100644 --- a/dvc/testing/benchmarks/cli/commands/test_plots.py +++ b/dvc/testing/benchmarks/cli/commands/test_plots.py @@ -1,10 +1,7 @@ -import pytest - from dvc.repo import Repo from dvc.testing.benchmarks.fixtures import _pull -@pytest.mark.requires(minversion=(2, 34, 0), reason="top-level plots not supported") def test_plots(project, bench_dvc): with Repo() as dvc: _pull(dvc) diff --git a/dvc/testing/benchmarks/fixtures.py b/dvc/testing/benchmarks/fixtures.py index 749d5ab37a..15d2da5b9c 100644 --- a/dvc/testing/benchmarks/fixtures.py +++ b/dvc/testing/benchmarks/fixtures.py @@ -118,32 +118,25 @@ def make_dvc_bin( def _dvc_bin(*args): return check_output([dvc_bin, *args], text=True) # noqa: S603 - _dvc_bin.version = parse_tuple(_dvc_bin("--version")) # type: ignore[attr-defined] + _dvc_bin.version = _dvc_bin("--version") # type: ignore[attr-defined] return _dvc_bin -def parse_tuple(version_string): - from packaging.version import Version - - parsed = version.parse(version_string) - assert isinstance(parsed, Version) - return (parsed.major, parsed.minor, parsed.micro) - - @pytest.fixture def dvc_bin(request, make_dvc_bin): if marker := request.node.get_closest_marker("requires"): - minversion = marker.kwargs.get("minversion") or first(marker.args) - assert minversion, ( - "'minversion' needs to be specified as" - " a positional or a keyword argument" - ) - reason = marker.kwargs.get("reason", "") - if isinstance(minversion, str): - minversion = parse_tuple(minversion) - if make_dvc_bin.version < minversion: - version_repr = ".".join(map(str, minversion)) - pytest.skip(f"requires dvc>={version_repr}: {reason}") + from packaging.specifiers import SpecifierSet + from packaging.version import Version + + spec = first(marker.args) + assert spec is not None + spec = SpecifierSet(spec) if isinstance(spec, str) else spec + reason = marker.kwargs["reason"] + if Version(make_dvc_bin.version) not in spec: + pytest.skip( + f"Version {make_dvc_bin.version} " + f"does not satisfy requirement {spec!r}: {reason}" + ) return make_dvc_bin diff --git a/dvc/testing/benchmarks/plugin.py b/dvc/testing/benchmarks/plugin.py index 9d3b142ec4..b1b9f9de14 100644 --- a/dvc/testing/benchmarks/plugin.py +++ b/dvc/testing/benchmarks/plugin.py @@ -30,7 +30,8 @@ def __init__(self): def pytest_configure(config): config.addinivalue_line( - "markers", "requires(minversion): mark a test as requiring minimum DVC version" + "markers", + "requires(spec): mark a test to run only on versions that satisfy the spec", ) config.bench_config = DVCBenchConfig()