Merge pull request #2680 from prokaktus/skipping-same-module
Fold skipped tests with global pytestmark variable
This commit is contained in:
commit
5c0feb2877
1
AUTHORS
1
AUTHORS
|
@ -117,6 +117,7 @@ Matt Bachmann
|
|||
Matt Duck
|
||||
Matt Williams
|
||||
Matthias Hafner
|
||||
Maxim Filipenko
|
||||
mbyt
|
||||
Michael Aquilina
|
||||
Michael Birtwell
|
||||
|
|
|
@ -345,6 +345,12 @@ def folded_skips(skipped):
|
|||
for event in skipped:
|
||||
key = event.longrepr
|
||||
assert len(key) == 3, (event, key)
|
||||
keywords = getattr(event, 'keywords', {})
|
||||
# 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:
|
||||
key = (key[0], None, key[2], )
|
||||
d.setdefault(key, []).append(event)
|
||||
l = []
|
||||
for key, events in d.items():
|
||||
|
@ -367,6 +373,11 @@ def show_skipped(terminalreporter, lines):
|
|||
for num, fspath, lineno, reason in fskips:
|
||||
if reason.startswith("Skipped: "):
|
||||
reason = reason[9:]
|
||||
lines.append(
|
||||
"SKIP [%d] %s:%d: %s" %
|
||||
(num, fspath, lineno + 1, reason))
|
||||
if lineno is not None:
|
||||
lines.append(
|
||||
"SKIP [%d] %s:%d: %s" %
|
||||
(num, fspath, lineno + 1, reason))
|
||||
else:
|
||||
lines.append(
|
||||
"SKIP [%d] %s: %s" %
|
||||
(num, fspath, reason))
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
Report only once tests with global ``pytestmark`` variable.
|
|
@ -676,6 +676,7 @@ def test_skip_reasons_folding():
|
|||
ev1.longrepr = longrepr
|
||||
|
||||
ev2 = X()
|
||||
ev2.when = "execute"
|
||||
ev2.longrepr = longrepr
|
||||
ev2.skipped = True
|
||||
|
||||
|
@ -713,6 +714,27 @@ def test_skipped_reasons_functional(testdir):
|
|||
assert result.ret == 0
|
||||
|
||||
|
||||
def test_skipped_folding(testdir):
|
||||
testdir.makepyfile(
|
||||
test_one="""
|
||||
import pytest
|
||||
pytestmark = pytest.mark.skip("Folding")
|
||||
def setup_function(func):
|
||||
pass
|
||||
def test_func():
|
||||
pass
|
||||
class TestClass(object):
|
||||
def test_method(self):
|
||||
pass
|
||||
""",
|
||||
)
|
||||
result = testdir.runpytest('-rs')
|
||||
result.stdout.fnmatch_lines([
|
||||
"*SKIP*2*test_one.py: Folding"
|
||||
])
|
||||
assert result.ret == 0
|
||||
|
||||
|
||||
def test_reportchars(testdir):
|
||||
testdir.makepyfile("""
|
||||
import pytest
|
||||
|
|
Loading…
Reference in New Issue