Merge pull request #2546 from blueyed/better-skip-not-allowed-error

[RFC] Improve error message for CollectError with skip/skipif
This commit is contained in:
Bruno Oliveira 2017-07-25 11:19:25 -03:00 committed by GitHub
commit 71947cb4f0
2 changed files with 5 additions and 3 deletions

View File

@ -442,9 +442,10 @@ class Module(main.File, PyCollector):
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

1
changelog/2546.trivial Normal file
View File

@ -0,0 +1 @@
Improve error message for CollectError with skip/skipif.