Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix #133 typing #135

Merged
merged 2 commits into from
Sep 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading