Skip to content

Commit

Permalink
Merge 6b0f5c6 into 1c5c741
Browse files Browse the repository at this point in the history
  • Loading branch information
pyup-bot committed Jan 11, 2021
2 parents 1c5c741 + 6b0f5c6 commit 97b2564
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 19 deletions.
3 changes: 2 additions & 1 deletion .travis.yml
Expand Up @@ -7,7 +7,8 @@ env:
- MAKE=ci
- MAKE=check-build
install:
- pip install -r devel.txt
- pip install -U pip
- pip install -U -r devel.txt
script:
- make $MAKE

Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
@@ -1,2 +1,2 @@
junitparser==1.6.3
junitparser==2.0.0
tcms-api==8.6.0
39 changes: 22 additions & 17 deletions tcms_junit_plugin/__init__.py
@@ -1,4 +1,4 @@
# Copyright (c) 2019 Alexander Todorov <atodorov@MrSenko.com>
# Copyright (c) 2019-2021 Alexander Todorov <atodorov@MrSenko.com>

# Licensed under the GPLv3: https://www.gnu.org/licenses/gpl.html

Expand Down Expand Up @@ -29,30 +29,35 @@ def parse(self, junit_xml, progress_cb=None):
summary = "%s.%s" % (xml_case.classname, xml_case.name)

test_case, _ = self.backend.test_case_get_or_create(summary)
test_case_id = test_case['id']

self.backend.add_test_case_to_plan(test_case_id,
self.backend.add_test_case_to_plan(test_case['id'],
self.backend.plan_id)

test_execution_id = self.backend.add_test_case_to_run(
test_case_id,
test_case['id'],
self.backend.run_id)
comment = 'Result recorded via Kiwi TCMS junit.xml-plugin'

if xml_case.result is None:
if not xml_case.result:
status_id = self.backend.get_status_id('PASSED')

if isinstance(xml_case.result, Failure):
status_id = self.backend.get_status_id('FAILED')
comment = xml_case.result.tostring()

if isinstance(xml_case.result, Error):
status_id = self.backend.get_status_id('ERROR')
comment = xml_case.result.tostring()

if isinstance(xml_case.result, Skipped):
status_id = self.backend.get_status_id('WAIVED')
comment = xml_case.result.message
# note: since junitpartser v2.0 the result attribute holds
# a list of values b/c pytest can produce files which contain
# multiple results for the same test case. We take the first!
for result in xml_case.result:
if isinstance(result, Failure):
status_id = self.backend.get_status_id('FAILED')
comment = result.tostring()
break

if isinstance(result, Error):
status_id = self.backend.get_status_id('ERROR')
comment = result.tostring()
break

if isinstance(result, Skipped):
status_id = self.backend.get_status_id('WAIVED')
comment = result.message
break

self.backend.update_test_execution(test_execution_id,
status_id,
Expand Down

0 comments on commit 97b2564

Please sign in to comment.