Skip to content

Commit

Permalink
Simplify FINAL_RESULTS and RERUN_RESULTS
Browse files Browse the repository at this point in the history
Co-authored-by: Jan Wille <[email protected]>
  • Loading branch information
EnricoMi and Cube707 authored Jan 14, 2025
1 parent 83268bf commit 91c5255
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
5 changes: 1 addition & 4 deletions junitparser/junitparser.py
Original file line number Diff line number Diff line change
Expand Up @@ -273,9 +273,6 @@ def __eq__(self, other):
return super().__eq__(other)


FINAL_RESULTS = {Failure, Error, Skipped}


class System(Element):
"""Parent class for :class:`SystemOut` and :class:`SystemErr`.
Expand Down Expand Up @@ -322,7 +319,7 @@ class TestCase(Element):
__test__ = False

# JUnit TestCase children are final results, SystemOut and SystemErr
ITER_TYPES = {t._tag: t for t in set.union(FINAL_RESULTS, {SystemOut, SystemErr})}
ITER_TYPES = {t._tag: t for t in (Failure, Error, Skipped, SystemOut, SystemErr)}

def __init__(self, name: str = None, classname: str = None, time: float = None):
super().__init__(self._tag)
Expand Down
11 changes: 7 additions & 4 deletions junitparser/xunit2.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,17 +172,20 @@ class FlakyError(InterimResult):
_tag = "flakyError"


RERUN_RESULTS = {RerunFailure, RerunError, FlakyFailure, FlakyError}


R = TypeVar("R", bound=InterimResult)


class TestCase(junitparser.TestCase):
group = junitparser.Attr()

# XUnit2 TestCase children are JUnit children and rerun results
ITER_TYPES = {t._tag: t for t in list(junitparser.TestCase.ITER_TYPES.values()) + list(RERUN_RESULTS)}
ITER_TYPES = {
t._tag: t
for t in itertools.chain(
junitparser.TestCase.ITER_TYPES.values(),
(RerunFailure, RerunError, FlakyFailure, FlakyError),
)
}

def _interim_results(self, _type: Type[R]) -> List[R]:
return [entry for entry in self if isinstance(entry, _type)]
Expand Down

0 comments on commit 91c5255

Please sign in to comment.