diff --git a/_pytest/skipping.py b/_pytest/skipping.py index ef9f601ca..0fe602972 100644 --- a/_pytest/skipping.py +++ b/_pytest/skipping.py @@ -349,7 +349,8 @@ 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 - if event.when == 'setup' and 'skip' in keywords and 'pytestmark' not in keywords: + when = getattr(event, 'when', None) + if when == 'setup' and 'skip' in keywords and 'pytestmark' not in keywords: key = (key[0], None, key[2], ) d.setdefault(key, []).append(event) l = [] diff --git a/testing/test_skipping.py b/testing/test_skipping.py index 23c4c37ce..ae334e7cd 100644 --- a/testing/test_skipping.py +++ b/testing/test_skipping.py @@ -663,7 +663,7 @@ def test_skipif_class(testdir): def test_skip_reasons_folding(): - path = 'xyz' + path = "xyz" lineno = 3 message = "justso" longrepr = (path, lineno, message) @@ -680,10 +680,15 @@ def test_skip_reasons_folding(): ev2.longrepr = longrepr ev2.skipped = True - l = folded_skips([ev1, ev2]) + # ev3 might be a collection report + ev3 = X() + ev3.longrepr = longrepr + ev3.skipped = True + + l = folded_skips([ev1, ev2, ev3]) assert len(l) == 1 num, fspath, lineno, reason = l[0] - assert num == 2 + assert num == 3 assert fspath == path assert lineno == lineno assert reason == message