Skip to content

Commit

Permalink
Decouple TestSuite from JUnitXml for inheritance
Browse files Browse the repository at this point in the history
  • Loading branch information
FlTr committed Feb 25, 2025
1 parent d540e64 commit 16553e8
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
5 changes: 3 additions & 2 deletions junitparser/junitparser.py
Original file line number Diff line number Diff line change
Expand Up @@ -509,6 +509,7 @@ class TestSuite(Element):
__test__ = False

testcase = TestCase
root = None

def __init__(self, name=None):
super().__init__(self._tag)
Expand Down Expand Up @@ -552,7 +553,7 @@ def __add__(self, other):
result.update_statistics()
else:
# Create a new test result containing two testsuites
result = JUnitXml()
result = JUnitXml() if TestSuite.root is None else TestSuite.root()
result.add_testsuite(self)
result.add_testsuite(other)
return result
Expand All @@ -566,7 +567,7 @@ def __iadd__(self, other):
self.update_statistics()
return self

result = JUnitXml()
result = JUnitXml() if TestSuite.root is None else TestSuite.root()
result.filepath = self.filepath
result.add_testsuite(self)
result.add_testsuite(other)
Expand Down
4 changes: 4 additions & 0 deletions junitparser/xunit2.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,10 @@ class TestSuite(junitparser.TestSuite):

testcase = TestCase

def __init__(self, name=None):
super().__init__(name)
TestSuite.root = JUnitXml

@property
def system_out(self):
"""<system-out>"""
Expand Down

0 comments on commit 16553e8

Please sign in to comment.