First argument in pytest.mark.skip is a reason
This commit is contained in:
parent
1b5aa2868d
commit
9e57954b03
|
@ -148,15 +148,24 @@ class MarkEvaluator(object):
|
||||||
|
|
||||||
@pytest.hookimpl(tryfirst=True)
|
@pytest.hookimpl(tryfirst=True)
|
||||||
def pytest_runtest_setup(item):
|
def pytest_runtest_setup(item):
|
||||||
eval_skipif = MarkEvaluator(item, 'skipif')
|
# Check if skip or skipif are specified as pytest marks
|
||||||
|
|
||||||
if eval_skipif.istrue():
|
skipif_info = item.keywords.get('skipif')
|
||||||
item._evalskip = eval_skipif
|
if isinstance(skipif_info, MarkInfo):
|
||||||
pytest.skip(eval_skipif.getexplanation())
|
eval_skipif = MarkEvaluator(item, 'skipif')
|
||||||
elif isinstance(item.keywords.get('skip'), MarkInfo):
|
if eval_skipif.istrue():
|
||||||
eval_skip = MarkEvaluator(item, 'skip')
|
item._evalskip = eval_skipif
|
||||||
item._evalskip = eval_skip
|
pytest.skip(eval_skipif.getexplanation())
|
||||||
pytest.skip(eval_skip.getexplanation())
|
|
||||||
|
skip_info = item.keywords.get('skip')
|
||||||
|
if isinstance(skip_info, MarkInfo):
|
||||||
|
item._evalskip = True
|
||||||
|
if 'reason' in skip_info.kwargs:
|
||||||
|
pytest.skip(skip_info.kwargs['reason'])
|
||||||
|
elif skip_info.args:
|
||||||
|
pytest.skip(skip_info.args[0])
|
||||||
|
else:
|
||||||
|
pytest.skip()
|
||||||
|
|
||||||
item._evalxfail = MarkEvaluator(item, 'xfail')
|
item._evalxfail = MarkEvaluator(item, 'xfail')
|
||||||
check_xfail_no_run(item)
|
check_xfail_no_run(item)
|
||||||
|
|
|
@ -409,6 +409,19 @@ class TestSkip(object):
|
||||||
rec = testdir.inline_run()
|
rec = testdir.inline_run()
|
||||||
rec.assertoutcome(skipped=1)
|
rec.assertoutcome(skipped=1)
|
||||||
|
|
||||||
|
def test_arg_as_reason(self, testdir):
|
||||||
|
testdir.makepyfile("""
|
||||||
|
import pytest
|
||||||
|
@pytest.mark.skip('testing stuff')
|
||||||
|
def test_bar():
|
||||||
|
pass
|
||||||
|
""")
|
||||||
|
result = testdir.runpytest('-rs')
|
||||||
|
result.stdout.fnmatch_lines([
|
||||||
|
"*testing stuff*",
|
||||||
|
"*1 skipped*",
|
||||||
|
])
|
||||||
|
|
||||||
def test_skip_no_reason(self, testdir):
|
def test_skip_no_reason(self, testdir):
|
||||||
testdir.makepyfile("""
|
testdir.makepyfile("""
|
||||||
import pytest
|
import pytest
|
||||||
|
|
Loading…
Reference in New Issue