From 8e55ac5029991b7c382048332f807eea871c5d00 Mon Sep 17 00:00:00 2001 From: Nikolay Golub Date: Mon, 6 Jun 2016 23:56:39 +0300 Subject: [PATCH] optimize testsuite parsing conditions Parsing of testsuite could be optimized, because el.tag cannot be a 'testcase' and 'properties' at same time, so other conditions are unnecessary --- xunitparser.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/xunitparser.py b/xunitparser.py index d72fe2b..eb8b023 100644 --- a/xunitparser.py +++ b/xunitparser.py @@ -171,11 +171,11 @@ def parse_testsuite(self, root, ts): for el in root: if el.tag == 'testcase': self.parse_testcase(el, ts) - if el.tag == 'properties': + elif el.tag == 'properties': self.parse_properties(el, ts) - if el.tag == 'system-out' and el.text: + elif el.tag == 'system-out' and el.text: ts.stdout = el.text.strip() - if el.tag == 'system-err' and el.text: + elif el.tag == 'system-err' and el.text: ts.stderr = el.text.strip() def parse_testcase(self, el, ts): @@ -200,7 +200,7 @@ def parse_testcase(self, el, ts): tc.time = to_timedelta(el.attrib.get('time')) if e.tag == 'system-out' and e.text: tc.stdout = e.text.strip() - if e.tag == 'system-err' and e.text: + elif e.tag == 'system-err' and e.text: tc.stderr = e.text.strip() # add either the original "success" tc or a tc created by elements