Fix regression when using importorskip at module level

Fix #1822
This commit is contained in:
Bruno Oliveira
2016-08-19 18:21:25 -03:00
parent 3a200b75c9
commit 63dc71c57e
4 changed files with 33 additions and 7 deletions

View File

@@ -431,7 +431,9 @@ class Module(pytest.File, PyCollector):
"Make sure your test modules/packages have valid Python names."
% (self.fspath, exc or exc_class)
)
except _pytest.runner.Skipped:
except _pytest.runner.Skipped as e:
if e.allow_module_level:
raise
raise self.CollectError(
"Using @pytest.skip outside a test (e.g. as a test function "
"decorator) is not allowed. Use @pytest.mark.skip or "