Skip to content

Commit

Permalink
Make deflake plugin handle other types of reports (#1692)
Browse files Browse the repository at this point in the history
Sometimes we get a `CollectReport`, which won't have the `should_retry` field set. Let's use `getattr` to avoid crashing in this case.
  • Loading branch information
sfc-gh-fcampbell authored Oct 10, 2024
1 parent 1d45ee3 commit dcea64b
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions tests_common/deflake.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ def pytest_runtest_protocol(self, item: Item, nextitem: Item | None) -> bool:

# Retry if the test reports that it should retry (report.should_retry is
# set by us in pytest_runtest_makereport below)
if any(report.should_retry for report in reports):
if any(getattr(report, "should_retry", False) for report in reports):
self.runner.runtestprotocol(item, nextitem=nextitem)

# Close the log line for this test
Expand Down Expand Up @@ -142,7 +142,7 @@ def pytest_report_teststatus(
self, report: TestReport
) -> tuple[str, str, str] | None:
# Hook into the terminal reporting of the test status
if report.should_retry:
if getattr(report, "should_retry", False):
# Don't log a status for this yet since it's not final
return "", "", ""
if report.outcome == FLAKY:
Expand Down

0 comments on commit dcea64b

Please sign in to comment.