Skip to content

Commit

Permalink
fix #133 typing (#135)
Browse files Browse the repository at this point in the history
Co-authored-by: Joel Wang <[email protected]>
  • Loading branch information
weiwei and Joel Wang authored Sep 1, 2024
1 parent b3fa30b commit 3c0db45
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
14 changes: 8 additions & 6 deletions junitparser/junitparser.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,9 @@
See the documentation for other supported schemas.
"""

import itertools
from copy import deepcopy
from typing import List
from typing import List, Union

try:
from lxml import etree
Expand Down Expand Up @@ -364,14 +363,17 @@ def result(self):
return results

@result.setter
def result(self, value: Result):
def result(self, value: Union[Result, List[Result]]):
# First remove all existing results
for entry in self.result:
if any(isinstance(entry, r) for r in POSSIBLE_RESULTS):
self.remove(entry)
for entry in value:
if any(isinstance(entry, r) for r in POSSIBLE_RESULTS):
self.append(entry)
if isinstance(value, Result):
self.append(value)
elif isinstance(value, list):
for entry in value:
if any(isinstance(entry, r) for r in POSSIBLE_RESULTS):
self.append(entry)

@property
def system_out(self):
Expand Down
3 changes: 2 additions & 1 deletion tests/test_general.py
Original file line number Diff line number Diff line change
Expand Up @@ -578,7 +578,8 @@ def test_case_output(self):

def test_update_results(self):
case = TestCase()
case.result = [Skipped()]
case.result = Skipped()
assert len(case.result) == 1
case.result = [Failure(), Skipped()]
assert len(case.result) == 2

Expand Down

0 comments on commit 3c0db45

Please sign in to comment.