Skip to content

Commit 1fbd19b

Browse files
committed
Fix pytest.mark.skip mark when used in strict mode
1 parent 725290a commit 1fbd19b

File tree

4 files changed

+23
-1
lines changed

4 files changed

+23
-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

+4-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@
77

88
*
99

10-
*
10+
* Fix ``pytest.mark.skip`` mark when used in strict mode.
11+
Thanks `@pquentin`_ for the PR and `@RonnyPfannschmidt`_ for
12+
showing how to fix the bug.
1113

1214
* Minor improvements and fixes to the documentation.
1315
Thanks `@omarkohl`_ for the PR.
@@ -165,6 +167,7 @@
165167
.. _@rabbbit: https://github.com/rabbbit
166168
.. _@hackebrot: https://github.com/hackebrot
167169
.. _@omarkohl: https://github.com/omarkohl
170+
.. _@pquentin: https://github.com/pquentin
168171

169172
2.8.7
170173
=====

_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)