Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: dev: Fix pytest source to show error and failure #19

Merged
merged 2 commits into from
Aug 22, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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