Add test for unconditional skip with reason
This commit is contained in:
parent
5f90907509
commit
d9ede1bac2
|
@ -551,14 +551,17 @@ class TestSkipif:
|
||||||
pytest_runtest_setup(item))
|
pytest_runtest_setup(item))
|
||||||
assert x.value.msg == "condition: hasattr(os, 'sep')"
|
assert x.value.msg == "condition: hasattr(os, 'sep')"
|
||||||
|
|
||||||
|
@pytest.mark.parametrize('params', [
|
||||||
def test_skipif_reporting(self, testdir):
|
'"hasattr(sys, \'platform\')"',
|
||||||
|
'True, reason="invalid platform"',
|
||||||
|
])
|
||||||
|
def test_skipif_reporting(self, testdir, params):
|
||||||
p = testdir.makepyfile(test_foo="""
|
p = testdir.makepyfile(test_foo="""
|
||||||
import pytest
|
import pytest
|
||||||
@pytest.mark.skipif("hasattr(sys, 'platform')")
|
@pytest.mark.skipif(%(params)s)
|
||||||
def test_that():
|
def test_that():
|
||||||
assert 0
|
assert 0
|
||||||
""")
|
""" % dict(params=params))
|
||||||
result = testdir.runpytest(p, '-s', '-rs')
|
result = testdir.runpytest(p, '-s', '-rs')
|
||||||
result.stdout.fnmatch_lines([
|
result.stdout.fnmatch_lines([
|
||||||
"*SKIP*1*test_foo.py*platform*",
|
"*SKIP*1*test_foo.py*platform*",
|
||||||
|
|
Loading…
Reference in New Issue