diff --git a/news/36c500b0-9c6e-49ca-bbdb-774ef0adbbfb.trivial.rst b/news/36c500b0-9c6e-49ca-bbdb-774ef0adbbfb.trivial.rst new file mode 100644 index 00000000000..e69de29bb2d diff --git a/tests/unit/test_utils_retry.py b/tests/unit/test_utils_retry.py index 74abce6f66f..74c543e4c75 100644 --- a/tests/unit/test_utils_retry.py +++ b/tests/unit/test_utils_retry.py @@ -77,22 +77,24 @@ def _raise_error() -> NoReturn: @pytest.mark.skipif( sys.platform == "win32", reason="Too flaky on Windows due to poor timer resolution" ) +@pytest.mark.flaky(reruns=3, reruns_delay=1) @pytest.mark.parametrize("wait_duration", [0.015, 0.045, 0.15]) def test_retry_wait(wait_duration: float) -> None: function, timestamps = create_timestamped_callable() - # Only the first retry will be scheduled before the time limit is exceeded. - wrapped = retry(wait=wait_duration, stop_after_delay=0.01)(function) + wrapped = retry(wait=wait_duration, stop_after_delay=0.1)(function) start_time = perf_counter() with pytest.raises(RuntimeError): wrapped() - assert len(timestamps) == 2 - # Add a margin of 10% to permit for unavoidable variation. + assert len(timestamps) >= 2 + # Just check the first retry, with a margin of 10% to permit for + # unavoidable variation. assert timestamps[1] - start_time >= (wait_duration * 0.9) @pytest.mark.skipif( sys.platform == "win32", reason="Too flaky on Windows due to poor timer resolution" ) +@pytest.mark.flaky(reruns=3, reruns_delay=1) @pytest.mark.parametrize( "call_duration, max_allowed_calls", [(0.01, 11), (0.04, 3), (0.15, 1)] ) @@ -113,7 +115,7 @@ class MyClass: def __init__(self) -> None: self.calls = 0 - @retry(wait=0, stop_after_delay=0.01) + @retry(wait=0, stop_after_delay=3) def method(self, string: str) -> str: self.calls += 1 if self.calls >= 5: