Skip to content

Commit 71947cb

Browse files
authored
Merge pull request #2546 from blueyed/better-skip-not-allowed-error
[RFC] Improve error message for CollectError with skip/skipif
2 parents 70d9f86 + 72531f3 commit 71947cb

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

_pytest/python.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -442,9 +442,10 @@ def _importtestmodule(self):
442442
if e.allow_module_level:
443443
raise
444444
raise self.CollectError(
445-
"Using pytest.skip outside of a test is not allowed. If you are "
446-
"trying to decorate a test function, use the @pytest.mark.skip "
447-
"or @pytest.mark.skipif decorators instead."
445+
"Using pytest.skip outside of a test is not allowed. "
446+
"To decorate a test function, use the @pytest.mark.skip "
447+
"or @pytest.mark.skipif decorators instead, and to skip a "
448+
"module use `pytestmark = pytest.mark.{skip,skipif}."
448449
)
449450
self.config.pluginmanager.consider_module(mod)
450451
return mod

changelog/2546.trivial

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Improve error message for CollectError with skip/skipif.

0 commit comments

Comments
 (0)