From 06307be15d2db8d327c5f6f82d07aa590b760472 Mon Sep 17 00:00:00 2001 From: "George Y. Kussumoto" Date: Sun, 1 Oct 2017 18:39:14 -0300 Subject: [PATCH] Add initial tests using skip with allow_module_level kwarg --- testing/test_skipping.py | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/testing/test_skipping.py b/testing/test_skipping.py index 1fbb9ed0f..23c4c37ce 100644 --- a/testing/test_skipping.py +++ b/testing/test_skipping.py @@ -1005,6 +1005,40 @@ def test_module_level_skip_error(testdir): ) +def test_module_level_skip_with_allow_module_level(testdir): + """ + Verify that using pytest.skip(allow_module_level=True) is allowed + """ + testdir.makepyfile(""" + import pytest + pytest.skip("skip_module_level", allow_module_level=True) + + def test_func(): + assert 0 + """) + result = testdir.runpytest("-rxs") + result.stdout.fnmatch_lines( + "*SKIP*skip_module_level" + ) + + +def test_invalid_skip_keyword_parameter(testdir): + """ + Verify that using pytest.skip() with unknown parameter raises an error + """ + testdir.makepyfile(""" + import pytest + pytest.skip("skip_module_level", unknown=1) + + def test_func(): + assert 0 + """) + result = testdir.runpytest() + result.stdout.fnmatch_lines( + "*TypeError:*['unknown']*" + ) + + def test_mark_xfail_item(testdir): # Ensure pytest.mark.xfail works with non-Python Item testdir.makeconftest("""