Skip to content

Commit

Permalink
Merge pull request #2546 from blueyed/better-skip-not-allowed-error
Browse files Browse the repository at this point in the history
[RFC] Improve error message for CollectError with skip/skipif
  • Loading branch information
nicoddemus authored Jul 25, 2017
2 parents 70d9f86 + 72531f3 commit 71947cb
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
7 changes: 4 additions & 3 deletions _pytest/python.py
Original file line number Diff line number Diff line change
Expand Up @@ -442,9 +442,10 @@ def _importtestmodule(self):
if e.allow_module_level:
raise
raise self.CollectError(
"Using pytest.skip outside of a test is not allowed. If you are "
"trying to decorate a test function, use the @pytest.mark.skip "
"or @pytest.mark.skipif decorators instead."
"Using pytest.skip outside of a test is not allowed. "
"To decorate a test function, use the @pytest.mark.skip "
"or @pytest.mark.skipif decorators instead, and to skip a "
"module use `pytestmark = pytest.mark.{skip,skipif}."
)
self.config.pluginmanager.consider_module(mod)
return mod
Expand Down
1 change: 1 addition & 0 deletions changelog/2546.trivial
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Improve error message for CollectError with skip/skipif.

0 comments on commit 71947cb

Please sign in to comment.