'Pytest plugin content in custom final section
I'm using the pytest-rerunfailures plugin to mark flaky tests in a large test suite. I like the addition the plugin makes to the output format as tests execute: I can see each test's status as it passes or fails, and if it fails, I can see the clearly-marked RERUN designation, followed by the next attempt at that test. This makes it easy to follow along as flaky tests fail and then get rerun.
However, pytest-rerunfailures does not show any RERUN information in the final "short test summary info" section of the terminal output (except for the final summary line, which doesn't show you which tests needed to be rerun) - it only shows Pass/Fail/Skipped/Xfail/Xpass/Error/Warning results (true even if pytest is run with the -rA command line option, wihch I did here):
I'd like to have the information from the first section available at the end of the test run so I don't have to scroll back pages and pages in the console to see which tests were rerun. I was looking at creating into a custom section at the end of the test run, based on the answer I found here. Using that tip, I'm able to print out a nice custom section (even in yellow, the same color the plugin marks RERUN outcomes). But I can't seem to figure out how to pull in the information I want: which tests were run when, and which of those required a rerun.
Can anyone lend a helping hand? Thank in advance!
Solution 1:[1]
It turns out that if you specify the -raR option when you run, you do get a final rerun info summary section. It's black and white though, and doesn't "flow" as well as the initial test session starts section. It would be clearer to present the final rerun info section in the same way as the initial section is presented: color-coded, and delineating each test attempt in succession, not just a summary of which tests required a rerun.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 |



