From b2516c56df96f1560d6752102218d2e172e47c0e Mon Sep 17 00:00:00 2001 From: Billy Vong Date: Fri, 22 Oct 2021 11:03:39 -0400 Subject: [PATCH] Ignore failures that are retried using `pytest-rerunfailures` plugin This change will not annotate test failures when there retries left to run via [`pytest-rerunfailures`](https://pypi.org/project/pytest-rerunfailures/) plugin --- pytest_github_actions_annotate_failures/plugin.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/pytest_github_actions_annotate_failures/plugin.py b/pytest_github_actions_annotate_failures/plugin.py index bdf4fff..cfaea99 100644 --- a/pytest_github_actions_annotate_failures/plugin.py +++ b/pytest_github_actions_annotate_failures/plugin.py @@ -27,6 +27,15 @@ def pytest_runtest_makereport(item, call): if os.environ.get("GITHUB_ACTIONS") != "true": return + try: + # If we have the pytest_rerunfailures plugin, and there are still + # retries to be run, then ignore error + import pytest_rerunfailures + if item.execution_count <= pytest_rerunfailures.get_reruns_count(item): + return + except ImportError: + pass + if report.when == "call" and report.failed: # collect information to be annotated filesystempath, lineno, _ = report.location