From f144666f8bcb468c89d938c919af4bc43c935704 Mon Sep 17 00:00:00 2001 From: Michael Aquilina Date: Mon, 21 Sep 2015 12:20:49 +0100 Subject: [PATCH] Work towards test coverage of mark.skip --- testing/test_skipping.py | 43 +++++++++++++++++++++++++++++++++++++++- 1 file changed, 42 insertions(+), 1 deletion(-) diff --git a/testing/test_skipping.py b/testing/test_skipping.py index 1048c9455..2d12af427 100644 --- a/testing/test_skipping.py +++ b/testing/test_skipping.py @@ -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