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"""
values = []
for rep in self.getreports(names=names):
try:
if not when and rep.when != "call" and rep.passed:
# setup/teardown passing reports - let's ignore those
continue
except AttributeError:
pass
if when and getattr(rep, "when", None) != when:
if not when and rep.when != "call" and rep.passed:
# setup/teardown passing reports - let's ignore those
continue
if when and rep.when != when:
continue
if not inamepart or inamepart in rep.nodeid.split("::"):
values.append(rep)
@ -338,7 +335,7 @@ class HookRecorder(object):
failed = []
for rep in self.getreports("pytest_collectreport pytest_runtest_logreport"):
if rep.passed:
if getattr(rep, "when", None) == "call":
if rep.when == "call":
passed.append(rep)
elif rep.skipped:
skipped.append(rep)

View File

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