From 26a24136d570106243c0434dd2e5b2108f42cfd9 Mon Sep 17 00:00:00 2001 From: skshetry <18718008+skshetry@users.noreply.github.com> Date: Mon, 4 Mar 2024 11:12:45 +0545 Subject: [PATCH] replace flaky with pytest-rerunfailures (#10335) * Revert "limit pytest version to <8.1 (#10334)" This reverts commit bc95b650a4c1ae935e3ea9d2d1af774060a4a96f. * replace flaky with pytest-rerunfailures `flaky` project seems to be unmaintained (see box/flaky#192). `pytest-rerunfailures` seems to be maintained under `pytest-dev` and tests 5 minor releases of pytest. Note that this plugin is not compatible with `flaky` plugin. You will have to uninstall it if it exists. --- dvc/testing/benchmarks/cli/commands/test_get.py | 2 +- dvc/testing/benchmarks/cli/commands/test_import.py | 2 +- pyproject.toml | 4 ++-- tests/conftest.py | 2 +- tests/func/test_data_cloud.py | 3 +-- 5 files changed, 6 insertions(+), 7 deletions(-) diff --git a/dvc/testing/benchmarks/cli/commands/test_get.py b/dvc/testing/benchmarks/cli/commands/test_get.py index 1eb6deb31e6..be5769e18b0 100644 --- a/dvc/testing/benchmarks/cli/commands/test_get.py +++ b/dvc/testing/benchmarks/cli/commands/test_get.py @@ -1,7 +1,7 @@ import pytest -@pytest.mark.flaky(max_runs=3, min_passes=1) +@pytest.mark.flaky(reruns=3) def test_get(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_import.py b/dvc/testing/benchmarks/cli/commands/test_import.py index 2580ec5a53d..f96295dd68e 100644 --- a/dvc/testing/benchmarks/cli/commands/test_import.py +++ b/dvc/testing/benchmarks/cli/commands/test_import.py @@ -1,7 +1,7 @@ import pytest -@pytest.mark.flaky(max_runs=3, min_passes=1) +@pytest.mark.flaky(reruns=3) 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/pyproject.toml b/pyproject.toml index ef4174f717b..1daec00a53f 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -102,8 +102,8 @@ tests = [ "beautifulsoup4>=4.4", "dvc-ssh", "filelock", - "flaky", - "pytest>=7,<8.1", + "pytest>=7,<9", + "pytest-rerunfailures", "pytest-cov>=4.1.0", "pytest-docker>=1,<4", "pytest-mock", diff --git a/tests/conftest.py b/tests/conftest.py index ab07015d35e..83abdcf9581 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -123,7 +123,7 @@ def pytest_runtest_setup(item): if "CI" in os.environ and item.get_closest_marker("needs_internet") is not None: # remotes that need internet connection might be flaky, # so we rerun them in case it fails. - item.add_marker(pytest.mark.flaky(max_runs=5, min_passes=1)) + item.add_marker(pytest.mark.flaky(reruns=5)) @pytest.fixture(scope="session") diff --git a/tests/func/test_data_cloud.py b/tests/func/test_data_cloud.py index e885c3d385c..e9acae0327f 100644 --- a/tests/func/test_data_cloud.py +++ b/tests/func/test_data_cloud.py @@ -3,7 +3,6 @@ import shutil import pytest -from flaky.flaky_decorator import flaky import dvc_data from dvc.cli import main @@ -207,7 +206,7 @@ def test_verify_hashes(tmp_dir, scm, dvc, mocker, tmp_path_factory, local_remote assert hash_spy.call_count == 10 -@flaky(max_runs=3, min_passes=1) +@pytest.mark.flaky(reruns=3) @pytest.mark.parametrize("erepo_type", ["git_dir", "erepo_dir"]) def test_pull_git_imports(request, tmp_dir, dvc, scm, erepo_type): erepo = request.getfixturevalue(erepo_type)