From e797fe696b3f44a938de792bd8b73a47a7dc9ab4 Mon Sep 17 00:00:00 2001 From: Saransh Chopra Date: Fri, 18 Oct 2024 10:21:06 +0100 Subject: [PATCH] gh-363: use pytest-rerunfailures for flaky test_ellipticity_gaussian (#371) Rerun the flaky test if it fails. See https://github.com/glass-dev/glass/pull/364#issuecomment-2414422872 Closes: #363 --- pyproject.toml | 1 + tests/test_shapes.py | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 9380bccf..08b2f0d2 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -58,6 +58,7 @@ test = [ "pytest-cov", "pytest-doctestplus", "pytest-mock", + "pytest-rerunfailures", "scipy", ] diff --git a/tests/test_shapes.py b/tests/test_shapes.py index f9744a6c..5f3bf3bc 100644 --- a/tests/test_shapes.py +++ b/tests/test_shapes.py @@ -89,6 +89,7 @@ def test_ellipticity_ryden04(rng: np.random.Generator) -> None: assert np.all((e.real >= -1.0) & (e.real <= 1.0)) +@pytest.mark.flaky(rerun=5, only_rerun=["AssertionError"]) def test_ellipticity_gaussian(rng: np.random.Generator) -> None: n = 1_000_000 @@ -105,7 +106,7 @@ def test_ellipticity_gaussian(rng: np.random.Generator) -> None: np.testing.assert_array_less(np.abs(eps), 1) np.testing.assert_allclose(np.std(eps.real), 0.256, atol=1e-3, rtol=0) - np.testing.assert_allclose(np.std(eps.imag), 0.256, atol=1e-2, rtol=0) + np.testing.assert_allclose(np.std(eps.imag), 0.256, atol=1e-3, rtol=0) eps = ellipticity_gaussian([n, n], [0.128, 0.256])