Skip to content

Commit 91c5255

Browse files
EnricoMiCube707
andauthored
Simplify FINAL_RESULTS and RERUN_RESULTS
Co-authored-by: Jan Wille <mail@janwille.de>
1 parent 83268bf commit 91c5255

2 files changed

Lines changed: 8 additions & 8 deletions

File tree

junitparser/junitparser.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -273,9 +273,6 @@ def __eq__(self, other):
273273
return super().__eq__(other)
274274

275275

276-
FINAL_RESULTS = {Failure, Error, Skipped}
277-
278-
279276
class System(Element):
280277
"""Parent class for :class:`SystemOut` and :class:`SystemErr`.
281278
@@ -322,7 +319,7 @@ class TestCase(Element):
322319
__test__ = False
323320

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

327324
def __init__(self, name: str = None, classname: str = None, time: float = None):
328325
super().__init__(self._tag)

junitparser/xunit2.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -172,17 +172,20 @@ class FlakyError(InterimResult):
172172
_tag = "flakyError"
173173

174174

175-
RERUN_RESULTS = {RerunFailure, RerunError, FlakyFailure, FlakyError}
176-
177-
178175
R = TypeVar("R", bound=InterimResult)
179176

180177

181178
class TestCase(junitparser.TestCase):
182179
group = junitparser.Attr()
183180

184181
# XUnit2 TestCase children are JUnit children and rerun results
185-
ITER_TYPES = {t._tag: t for t in list(junitparser.TestCase.ITER_TYPES.values()) + list(RERUN_RESULTS)}
182+
ITER_TYPES = {
183+
t._tag: t
184+
for t in itertools.chain(
185+
junitparser.TestCase.ITER_TYPES.values(),
186+
(RerunFailure, RerunError, FlakyFailure, FlakyError),
187+
)
188+
}
186189

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

0 commit comments

Comments
 (0)