resolving report.when attribute should be reliable now

This commit is contained in:
wim glenn 2019-01-24 11:12:59 -06:00
parent 0f546c4670
commit 2d18546870
No known key found for this signature in database
GPG Key ID: C127F552CFFFC6DE
2 changed files with 10 additions and 10 deletions

View File

@ -305,13 +305,10 @@ class HookRecorder(object):
"""return a testreport whose dotted import path matches""" """return a testreport whose dotted import path matches"""
values = [] values = []
for rep in self.getreports(names=names): for rep in self.getreports(names=names):
try: if not when and rep.when != "call" and rep.passed:
if not when and rep.when != "call" and rep.passed: # setup/teardown passing reports - let's ignore those
# setup/teardown passing reports - let's ignore those continue
continue if when and rep.when != when:
except AttributeError:
pass
if when and getattr(rep, "when", None) != when:
continue continue
if not inamepart or inamepart in rep.nodeid.split("::"): if not inamepart or inamepart in rep.nodeid.split("::"):
values.append(rep) values.append(rep)
@ -338,7 +335,7 @@ class HookRecorder(object):
failed = [] failed = []
for rep in self.getreports("pytest_collectreport pytest_runtest_logreport"): for rep in self.getreports("pytest_collectreport pytest_runtest_logreport"):
if rep.passed: if rep.passed:
if getattr(rep, "when", None) == "call": if rep.when == "call":
passed.append(rep) passed.append(rep)
elif rep.skipped: elif rep.skipped:
skipped.append(rep) skipped.append(rep)

View File

@ -244,8 +244,11 @@ def folded_skips(skipped):
# folding reports with global pytestmark variable # folding reports with global pytestmark variable
# this is workaround, because for now we cannot identify the scope of a skip marker # this is workaround, because for now we cannot identify the scope of a skip marker
# TODO: revisit after marks scope would be fixed # TODO: revisit after marks scope would be fixed
when = getattr(event, "when", None) if (
if when == "setup" and "skip" in keywords and "pytestmark" not in keywords: event.when == "setup"
and "skip" in keywords
and "pytestmark" not in keywords
):
key = (key[0], None, key[2]) key = (key[0], None, key[2])
d.setdefault(key, []).append(event) d.setdefault(key, []).append(event)
values = [] values = []