Extract the nouns from a pytest terminal summary line. It always returns the plural noun for consistency:: ======= 1 failed, 1 passed, 1 warning, 1 error in 0.13s ==== Will return ``{"failed": 1, "passed": 1, "warnings": 1, "errors": 1}``.
(cls, lines)
| 568 | |
| 569 | @classmethod |
| 570 | def parse_summary_nouns(cls, lines) -> dict[str, int]: |
| 571 | class="st">"""Extract the nouns from a pytest terminal summary line. |
| 572 | |
| 573 | It always returns the plural noun for consistency:: |
| 574 | |
| 575 | ======= 1 failed, 1 passed, 1 warning, 1 error in 0.13s ==== |
| 576 | |
| 577 | Will return ``{class="st">"failed": 1, class="st">"passed": 1, class="st">"warnings": 1, class="st">"errors": 1}``. |
| 578 | class="st">""" |
| 579 | for line in reversed(lines): |
| 580 | if rex_session_duration.search(line): |
| 581 | outcomes = rex_outcome.findall(line) |
| 582 | ret = {noun: int(count) for (count, noun) in outcomes} |
| 583 | break |
| 584 | else: |
| 585 | raise ValueError(class="st">"Pytest terminal summary report not found") |
| 586 | |
| 587 | to_plural = { |
| 588 | class="st">"warning": class="st">"warnings", |
| 589 | class="st">"error": class="st">"errors", |
| 590 | } |
| 591 | return {to_plural.get(k, k): v for k, v in ret.items()} |
| 592 | |
| 593 | def assert_outcomes( |
| 594 | self, |
no test coverage detected