Add test for unconditional skip with reason

This commit is contained in:
Bruno Oliveira 2016-02-25 20:02:34 -03:00
parent 5f90907509
commit d9ede1bac2
1 changed files with 7 additions and 4 deletions

View File

@ -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*",