Work towards test coverage of mark.skip

This commit is contained in:
Michael Aquilina 2015-09-21 12:20:49 +01:00
parent 4e94135d36
commit f144666f8b
1 changed files with 42 additions and 1 deletions

View File

@ -382,7 +382,48 @@ class TestXFailwithSetupTeardown:
])
class TestSkipif:
class TestSkip(object):
def test_skip_no_reason(self, testdir):
testdir.makepyfile("""
import pytest
@pytest.mark.skip
def test_foo():
pass
""")
rec = testdir.inline_run()
rec.assertoutcome(skipped=1)
def test_skip_with_reason(self, testdir):
testdir.makepyfile("""
import pytest
@pytest.mark.skip(reason="for lolz")
def test_bar():
pass
""")
# cant use assertoutcome because we cant
# also check the reason
result = testdir.runpytest('-rs')
result.stdout.fnmatch_lines([
"*for lolz*",
"*1 skipped*",
])
def test_only_skips_marked_test(self, testdir):
testdir.makepyfile("""
import pytest
@pytest.mark.skip
def test_foo():
pass
@pytest.mark.skip(reason="none")
def test_bar() :
pass
def test_baz():
assert True
""")
rec = testdir.inline_run()
rec.assertoutcome(passed=1, skipped=2)
class TestSkipif(object):
def test_skipif_conditional(self, testdir):
item = testdir.getitem("""
import pytest