Aggregate flaky tests across runs and count total reruns.
(
all_flaky_tests: list[dict[str, Any]],
)
| 135 | |
| 136 | |
| 137 | def _aggregate_flaky_tests( |
| 138 | all_flaky_tests: list[dict[str, Any]], |
| 139 | ) -> list[dict[str, Any]]: |
| 140 | """Aggregate flaky tests across runs and count total reruns.""" |
| 141 | rerun_counts: Counter[str] = Counter() |
| 142 | browser_rerun_counts: Counter[str] = Counter() |
| 143 | browser_info: dict[str, set[str]] = {} |
| 144 | |
| 145 | for test in all_flaky_tests: |
| 146 | normalized = _normalize_test_name(test["nodeid"]) |
| 147 | rerun_counts[normalized] += test["rerun_count"] |
| 148 | browser_rerun_counts[normalized] += ( |
| 149 | 1 # Counts browser-specific entries, not distinct CI runs |
| 150 | ) |
| 151 | browser_info.setdefault(normalized, set()).add(test["browser"]) |
| 152 | |
| 153 | results = [ |
| 154 | { |
| 155 | "nodeid": nodeid, |
| 156 | "total_reruns": total_reruns, |
| 157 | "browser_rerun_count": browser_rerun_counts[nodeid], |
| 158 | "browsers": sorted(browser_info[nodeid]), |
| 159 | } |
| 160 | for nodeid, total_reruns in rerun_counts.items() |
| 161 | ] |
| 162 | |
| 163 | results.sort(key=_sort_key) |
| 164 | return results |
| 165 | |
| 166 | |
| 167 | def main() -> None: |
no test coverage detected
searching dependent graphs…