MCPcopy Index your code
hub / github.com/python/cpython / write_junit

Method write_junit

Lib/test/libregrtest/results.py:180–203  ·  view source on GitHub ↗
(self, filename: StrPath)

Source from the content-addressed store, hash-verified

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()

Callers 1

finalize_testsMethod · 0.80

Calls 7

appendMethod · 0.95
setMethod · 0.95
strFunction · 0.85
openFunction · 0.50
getMethod · 0.45
itemsMethod · 0.45
writeMethod · 0.45

Tested by

no test coverage detected