Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
angelos-p opened this issue May 30, 2024 · 2 comments · May be fixed by #836
Open

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

angelos-p opened this issue May 30, 2024 · 2 comments · May be fixed by #836

Comments

@angelos-p
Copy link

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'
@rambhupala-merla
Copy link

I am also facing the same issue

@acolombier acolombier linked a pull request Oct 11, 2024 that will close this issue
@cbspencer66
Copy link

cbspencer66 commented Oct 15, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants