Fix double <system-out> entry in junit.xml

check it system-out already exists
if this is the case append text
This commit is contained in:
Kai Kasprowsky 2023-03-27 15:03:17 +02:00
parent 2369bed1db
commit ca782ca4f3
3 changed files with 14 additions and 3 deletions

1
10841.improvement.rst Normal file
View File

@ -0,0 +1 @@
only create <system-out> in junit.xml once for each test.

View File

@ -189,6 +189,7 @@ Joshua Bronson
Jurko Gospodnetić
Justice Ndou
Justyna Janczyszyn
Kai Kasprowsky
Kale Kundert
Kamran Ahmad
Karl O. Pinc

View File

@ -186,9 +186,18 @@ class _NodeReporter:
return "\n".join([header.center(80, "-"), content, ""])
def _write_content(self, report: TestReport, content: str, jheader: str) -> None:
tag = ET.Element(jheader)
tag.text = bin_xml_escape(content)
self.append(tag)
exists = False
for elem in next(iter(self.xml.node_reporters.values())).nodes:
if jheader in elem.tag:
exists = True
tag = elem
tag.text = (
tag.text + bin_xml_escape(content) if tag.text is not None else None
)
if not exists:
tag = ET.Element(jheader)
tag.text = bin_xml_escape(content)
self.append(tag)
def append_pass(self, report: TestReport) -> None:
self.add_stats("passed")