File tree 3 files changed +6
-5
lines changed 3 files changed +6
-5
lines changed Original file line number Diff line number Diff line change
1
+ Improve error message when :func: `pytest.skip ` is used at module level without passing `allow_module_level=True `.
Original file line number Diff line number Diff line change @@ -608,10 +608,10 @@ def _importtestmodule(self):
608
608
if e .allow_module_level :
609
609
raise
610
610
raise self .CollectError (
611
- "Using pytest.skip outside of a test is not allowed . "
612
- "To decorate a test function, use the @pytest.mark.skip "
613
- "or @pytest.mark.skipif decorators instead, and to skip a "
614
- "module use `pytestmark = pytest.mark.{ skip, skipif} ."
611
+ "Using pytest.skip outside of a test will skip the entire module . "
612
+ "If that's your intention, pass `allow_module_level=True`. "
613
+ "If you want to skip a specific test or an entire class, "
614
+ "use the @ pytest.mark.skip or @pytest.mark. skipif decorators ."
615
615
) from e
616
616
self .config .pluginmanager .consider_module (mod )
617
617
return mod
Original file line number Diff line number Diff line change @@ -1341,7 +1341,7 @@ def test_func():
1341
1341
)
1342
1342
result = pytester .runpytest ()
1343
1343
result .stdout .fnmatch_lines (
1344
- ["*Using pytest.skip outside of a test is not allowed *" ]
1344
+ ["*Using pytest.skip outside of a test will skip the entire module *" ]
1345
1345
)
1346
1346
1347
1347
You can’t perform that action at this time.
0 commit comments