From 72531f30c0d8834230f2007fe5b563c9fe5af04b Mon Sep 17 00:00:00 2001 From: Daniel Hahler Date: Tue, 4 Jul 2017 12:16:42 +0200 Subject: [PATCH] Improve error message for CollectError with skip/skipif --- _pytest/python.py | 7 ++++--- changelog/2546.trivial | 1 + 2 files changed, 5 insertions(+), 3 deletions(-) create mode 100644 changelog/2546.trivial diff --git a/_pytest/python.py b/_pytest/python.py index d0f13a758c9..29e3182d4ad 100644 --- a/_pytest/python.py +++ b/_pytest/python.py @@ -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 diff --git a/changelog/2546.trivial b/changelog/2546.trivial new file mode 100644 index 00000000000..53e43bc1792 --- /dev/null +++ b/changelog/2546.trivial @@ -0,0 +1 @@ +Improve error message for CollectError with skip/skipif.