Skip to content

Commit d83e1f4

Browse files
committed
Fix pytest.mark.skip mark when used in strict mode
1 parent 890c2fa commit d83e1f4

File tree

4 files changed

+21
-1
lines changed

4 files changed

+21
-1
lines changed

AUTHORS

+1
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ Nicolas Delaby
6969
Pieter Mulder
7070
Piotr Banaszkiewicz
7171
Punyashloka Biswal
72+
Quentin Pradet
7273
Ralf Schmitt
7374
Raphael Pierzina
7475
Ronny Pfannschmidt

CHANGELOG.rst

+2-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@
77

88
*
99

10-
*
10+
* Fix ``pytest.mark.skip`` mark when used in strict mode.
11+
Thanks `@pquentin`_ for the PR.
1112

1213
* Minor improvements and fixes to the documentation.
1314
Thanks `@omarkohl`_ for the PR.

_pytest/skipping.py

+5
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,11 @@ def nop(*args, **kwargs):
3030
nop.Exception = XFailed
3131
setattr(pytest, "xfail", nop)
3232

33+
config.addinivalue_line("markers",
34+
"skip(reason=None): skip the given test function with an optional reason. "
35+
"Example: skip(reason=\"no way of currently testing this\") skips the "
36+
"test."
37+
)
3338
config.addinivalue_line("markers",
3439
"skipif(condition): skip the given test function if eval(condition) "
3540
"results in a True value. Evaluation happens within the "

testing/test_skipping.py

+13
Original file line numberDiff line numberDiff line change
@@ -539,6 +539,19 @@ def test_baz():
539539
"*1 passed*2 skipped*",
540540
])
541541

542+
def test_strict_and_skip(self, testdir):
543+
testdir.makepyfile("""
544+
import pytest
545+
@pytest.mark.skip
546+
def test_hello():
547+
pass
548+
""")
549+
result = testdir.runpytest("-rs --strict")
550+
result.stdout.fnmatch_lines([
551+
"*unconditional skip*",
552+
"*1 skipped*",
553+
])
554+
542555
class TestSkipif:
543556
def test_skipif_conditional(self, testdir):
544557
item = testdir.getitem("""

0 commit comments

Comments
 (0)