From 088313d6d29aa98f4ccc9687fd617a6dce9fe7b5 Mon Sep 17 00:00:00 2001 From: Jonathan Karlsen Date: Mon, 4 Mar 2024 14:02:12 +0100 Subject: [PATCH] Change from using flaky to pytest_rerunfailures --- pyproject.toml | 4 ++-- .../integration_tests/storage/test_parameter_sample_types.py | 3 +-- tests/performance_tests/test_memory_usage.py | 3 +-- tests/unit_tests/job_queue/test_ert_qstat_proxy.py | 3 +-- tests/unit_tests/job_runner/test_event_reporter.py | 3 +-- tests/unit_tests/job_runner/test_job.py | 3 +-- tests/unit_tests/scheduler/test_scheduler.py | 5 ++--- 7 files changed, 9 insertions(+), 15 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 8d4ad14f79f..9e172667bc2 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -94,7 +94,6 @@ Repository = "https://github.com/equinor/ert" dev = [ "decorator", "furo", - "flaky", "hypothesis", "jsonpath_ng", "jupytext", @@ -107,10 +106,11 @@ dev = [ "pytest-mpl", "pytest-qt", "pytest-raises", + "pytest-rerunfailures", "pytest-snapshot", "pytest-timeout", "pytest-xdist", - "pytest>6,<8.1.0", + "pytest>6", "resfo", "scikit-learn", "sphinx", diff --git a/tests/integration_tests/storage/test_parameter_sample_types.py b/tests/integration_tests/storage/test_parameter_sample_types.py index c3b95e65145..f105358a510 100644 --- a/tests/integration_tests/storage/test_parameter_sample_types.py +++ b/tests/integration_tests/storage/test_parameter_sample_types.py @@ -7,7 +7,6 @@ import numpy as np import pytest import xtgeo -from flaky import flaky from ert.cli import ENSEMBLE_SMOOTHER_MODE from ert.libres_facade import LibresFacade @@ -179,7 +178,7 @@ def test_surface_param_update(tmpdir): @pytest.mark.integration_test @pytest.mark.limit_memory("110 MB") -@flaky(max_runs=5, min_passes=1) +@pytest.mark.flaky(reruns=5) def test_field_param_memory(tmpdir): with tmpdir.as_cwd(): # Setup is done in a subprocess so that memray does not pick up the allocations diff --git a/tests/performance_tests/test_memory_usage.py b/tests/performance_tests/test_memory_usage.py index 0d01c678d22..3c836fc9b18 100644 --- a/tests/performance_tests/test_memory_usage.py +++ b/tests/performance_tests/test_memory_usage.py @@ -7,7 +7,6 @@ import py import pytest import xarray as xr -from flaky import flaky from ert.analysis import smoother_update from ert.config import ErtConfig, SummaryConfig @@ -40,7 +39,7 @@ def poly_template(monkeypatch): yield folder -@flaky(max_runs=5, min_passes=1) +@pytest.mark.flaky(reruns=5) @pytest.mark.limit_memory("130 MB") @pytest.mark.integration_test def test_memory_smoothing(poly_template): diff --git a/tests/unit_tests/job_queue/test_ert_qstat_proxy.py b/tests/unit_tests/job_queue/test_ert_qstat_proxy.py index 98724babaa3..3b866133494 100644 --- a/tests/unit_tests/job_queue/test_ert_qstat_proxy.py +++ b/tests/unit_tests/job_queue/test_ert_qstat_proxy.py @@ -10,7 +10,6 @@ import pytest import testpath -from flaky import flaky from ert import _clib @@ -241,7 +240,7 @@ def test_options_passed_through_proxy(tmpdir, options, expected, monkeypatch): # (the output from the mocked qstat happens to adhere to json syntax) -@flaky +@pytest.mark.flaky(reruns=5) @pytest.mark.skipif(sys.platform.startswith("darwin"), reason="No flock on MacOS") def test_many_concurrent_qstat_invocations(tmpdir, monkeypatch): """Run many qstat invocations simultaneously, with a mocked backend qstat diff --git a/tests/unit_tests/job_runner/test_event_reporter.py b/tests/unit_tests/job_runner/test_event_reporter.py index c368246a4e1..92354353496 100644 --- a/tests/unit_tests/job_runner/test_event_reporter.py +++ b/tests/unit_tests/job_runner/test_event_reporter.py @@ -5,7 +5,6 @@ from unittest.mock import patch import pytest -from flaky import flaky from _ert_job_runner.client import ClientConnectionClosedOK, ClientConnectionError from _ert_job_runner.job import Job @@ -200,7 +199,7 @@ def mock_send(msg): assert len(lines) == 0, "expected 0 Job running messages" -@flaky +@pytest.mark.flaky(reruns=5) @pytest.mark.skipif( sys.platform.startswith("darwin"), reason="Performance can be flaky" ) diff --git a/tests/unit_tests/job_runner/test_job.py b/tests/unit_tests/job_runner/test_job.py index 7acee917b26..d9a5280f6cc 100644 --- a/tests/unit_tests/job_runner/test_job.py +++ b/tests/unit_tests/job_runner/test_job.py @@ -3,7 +3,6 @@ from unittest.mock import PropertyMock, patch import pytest -from flaky import flaky from _ert_job_runner.job import Job from _ert_job_runner.reporting.message import Exited, Running, Start @@ -34,7 +33,7 @@ def test_run_with_process_failing( next(run) -@flaky +@pytest.mark.flaky(reruns=5) @pytest.mark.usefixtures("use_tmpdir") def test_memory_usage_counts_grandchildren(): scriptname = "recursive_memory_hog.py" diff --git a/tests/unit_tests/scheduler/test_scheduler.py b/tests/unit_tests/scheduler/test_scheduler.py index be73695d8c0..407968e13fd 100644 --- a/tests/unit_tests/scheduler/test_scheduler.py +++ b/tests/unit_tests/scheduler/test_scheduler.py @@ -8,7 +8,6 @@ import pytest from cloudevents.http import from_json -from flaky import flaky from ert.constant_filenames import CERT_FILE from ert.ensemble_evaluator._builder._realization import Realization @@ -381,7 +380,7 @@ async def wait(iens): assert killed_iens == [6, 7, 8, 9] -@flaky(max_runs=5, min_passes=1) +@pytest.mark.flaky(reruns=5) @pytest.mark.parametrize( "submit_sleep, iens_stride, realization_runtime", [(0, 1, 0.1), (0.1, 1, 0.1), (0.1, 1, 0), (0.1, 2, 0)], @@ -424,7 +423,7 @@ async def wait(): assert max(deltas) <= submit_sleep + 0.1 -@flaky(max_runs=5, min_passes=1) +@pytest.mark.flaky(reruns=5) @pytest.mark.parametrize( "submit_sleep, realization_max_runtime, max_running", [