From efdbc21ea7568ad72e322cbbc6697a943ac9c9cc Mon Sep 17 00:00:00 2001 From: Gabriel Augendre Date: Sat, 9 Jan 2021 19:02:22 +0100 Subject: [PATCH] Configure pytest to automatically rerun a flaky test --- articles/tests/test_admin.py | 1 + poetry.lock | 17 ++++++++++++++++- pyproject.toml | 1 + 3 files changed, 18 insertions(+), 1 deletion(-) diff --git a/articles/tests/test_admin.py b/articles/tests/test_admin.py index 6838b9f..23825c5 100644 --- a/articles/tests/test_admin.py +++ b/articles/tests/test_admin.py @@ -6,6 +6,7 @@ from articles.models import User @pytest.mark.django_db +@pytest.mark.flaky(reruns=5, reruns_delay=3) def test_can_access_add_article(client: Client, author: User): client.force_login(author) res = client.get(reverse("admin:articles_article_add")) diff --git a/poetry.lock b/poetry.lock index a7d5aa8..5190b62 100644 --- a/poetry.lock +++ b/poetry.lock @@ -470,6 +470,17 @@ attrs = "*" pytest = ">=3.5.0" vcrpy = ">=2.0.1" +[[package]] +name = "pytest-rerunfailures" +version = "9.1.1" +description = "pytest plugin to re-run tests to eliminate flaky failures" +category = "dev" +optional = false +python-versions = ">=3.5" + +[package.dependencies] +pytest = ">=5.0" + [[package]] name = "pytz" version = "2020.5" @@ -633,7 +644,7 @@ multidict = ">=4.0" [metadata] lock-version = "1.1" python-versions = "^3.8" -content-hash = "95c3ac9ea5b53ca0646c04fe708143d8affe331c1a0b71204b59315f00347d4f" +content-hash = "54f79231676e4ef08e19081303d6bdf9c18bd2db967b7df46bc489a056046d41" [metadata.files] appdirs = [ @@ -960,6 +971,10 @@ pytest-recording = [ {file = "pytest-recording-0.11.0.tar.gz", hash = "sha256:deea1ae6a129c9d8f8669ed7d12539748f00c8f9ef4de4f563055263e47bed08"}, {file = "pytest_recording-0.11.0-py3-none-any.whl", hash = "sha256:c2cc321f93ceffb2146ead0c51198e4ce86986723265ce6d4a87d3b16071eb85"}, ] +pytest-rerunfailures = [ + {file = "pytest-rerunfailures-9.1.1.tar.gz", hash = "sha256:1cb11a17fc121b3918414eb5eaf314ee325f2e693ac7cb3f6abf7560790827f2"}, + {file = "pytest_rerunfailures-9.1.1-py3-none-any.whl", hash = "sha256:2eb7d0ad651761fbe80e064b0fd415cf6730cdbc53c16a145fd84b66143e609f"}, +] pytz = [ {file = "pytz-2020.5-py2.py3-none-any.whl", hash = "sha256:16962c5fb8db4a8f63a26646d8886e9d769b6c511543557bc84e9569fb9a9cb4"}, {file = "pytz-2020.5.tar.gz", hash = "sha256:180befebb1927b16f6b57101720075a984c019ac16b1b7575673bea42c6c3da5"}, diff --git a/pyproject.toml b/pyproject.toml index b89c878..fa40b4d 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -44,6 +44,7 @@ pytest-django = "^3.9" model-bakery = "^1.1" pytest-cov = "^2.10.1" pytest-recording = "^0.11.0" +pytest-rerunfailures = "^9.1.1" [build-system] requires = ["poetry-core>=1.0.0"]