| 178 | raise |
| 179 | |
| 180 | def write_junit(self, filename: StrPath) -> None: |
| 181 | if not self.testsuite_xml: |
| 182 | # Don't create empty XML file |
| 183 | return |
| 184 | |
| 185 | import xml.etree.ElementTree as ET |
| 186 | root = ET.Element("testsuites") |
| 187 | |
| 188 | # Manually count the totals for the overall summary |
| 189 | totals = {'tests': 0, 'errors': 0, 'failures': 0} |
| 190 | for suite in self.testsuite_xml: |
| 191 | root.append(suite) |
| 192 | for k in totals: |
| 193 | try: |
| 194 | totals[k] += int(suite.get(k, 0)) |
| 195 | except ValueError: |
| 196 | pass |
| 197 | |
| 198 | for k, v in totals.items(): |
| 199 | root.set(k, str(v)) |
| 200 | |
| 201 | with open(filename, 'wb') as f: |
| 202 | for s in ET.tostringlist(root): |
| 203 | f.write(s) |
| 204 | |
| 205 | def display_result(self, tests: TestTuple, quiet: bool, print_slowest: bool) -> None: |
| 206 | ansi = get_colors() |