Skip to content

Crashes with KeyError: 'retried' when test is retried with pytest-retry #815

Closed

Description

@angelos-p

It looks like the html reporter does not handle tests with the outcome retried.

It's quite easy to reproduce:

  1. Create a failing test with the mark @pytest.mark.flaky(retries=3, delay=1)
  2. Run the test and wait for it to fail so that it is retried
  3. Pytest crashes with:
File "/__w/xi/xi/tests/venv/lib/python3.9/site-packages/pytest_html/report_data.py", line 94, in outcomes
  self._outcomes[outcome.lower()]["value"] += 1
KeyError: 'retried'

Activity

  1. rambhupala-merla commented on Sep 20, 2024

    @rambhupala-merla

    I am also facing the same issue

  2. cbspencer66 commented on Oct 15, 2024

    @cbspencer66

    I encountered the same issue as well, and found what seems to be a solution (at least in my case). The solution requires two minor changes to the pytest_html module files, basereport.py and report_data.py:

    In basereport.py, add "retried" to the relevant_outcomes list.

    In report_data.py, add the following to the self._outcomes dict in class ReportData:

    "retried": {"label": "Retries", "value": 0}

    I made these changes to pytest-html 4.1.1, which appears to be the latest version.

  3. ETreskovskis commented on Dec 2, 2024

    @ETreskovskis

    @angelos-p @cbspencer66 pytest-rerunfailures plugin works fine with the latest pytest-html version. Until pytest-retry fix would merged.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions