Skip to content

Commit

Permalink
fix: dev: Fix pytest source to show error and failure
Browse files Browse the repository at this point in the history
  • Loading branch information
dajose authored and carlos-jenkins committed Aug 22, 2018
1 parent 223a9d1 commit ff0fd1d
Showing 1 changed file with 19 additions and 14 deletions.
33 changes: 19 additions & 14 deletions lib/flowbber/plugins/sources/pytest.py
Original file line number Diff line number Diff line change
Expand Up @@ -212,25 +212,30 @@ def collect(self):
# Add test cases
for child in root:
assert child.tag == 'testcase', 'Malformed XML child element'
testcase = {
key: cast(child.attrib[key])
for key, cast in [
('file', str),
('line', int),
('classname', str),
('name', str),
('time', float),
]
}

properties = []
testcase['properties'] = properties

# Form an unique name base on classname and testcase name
tckey = '{}.{}'.format(
child.attrib['classname'],
child.attrib['name']
)
testcases[tckey] = testcase
# Pytest creates duplicates of a test case if there is an error and
# a failure. It does so in order to be compliant with JUnit schema
# See https://github.com/pytest-dev/pytest/issues/2228
testcase = testcases.get(tckey)
if testcase is None:
testcase = {
key: cast(child.attrib[key])
for key, cast in [
('file', str),
('line', int),
('classname', str),
('name', str),
('time', float),
]
}
properties = []
testcase['properties'] = properties
testcases[tckey] = testcase

# Add properties
subchild = child.find('properties')
Expand Down

0 comments on commit ff0fd1d

Please sign in to comment.