From 79d33530812748482726a82a45b0e2754928c756 Mon Sep 17 00:00:00 2001 From: "George Y. Kussumoto" Date: Sun, 1 Oct 2017 18:38:29 -0300 Subject: [PATCH] Add allow_module_level kwarg to skip helper --- _pytest/outcomes.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/_pytest/outcomes.py b/_pytest/outcomes.py index ff5ef756d..75b0250f4 100644 --- a/_pytest/outcomes.py +++ b/_pytest/outcomes.py @@ -62,14 +62,21 @@ def exit(msg): exit.Exception = Exit -def skip(msg=""): +def skip(msg="", **kwargs): """ skip an executing test with the given message. Note: it's usually better to use the pytest.mark.skipif marker to declare a test to be skipped under certain conditions like mismatching platforms or dependencies. See the pytest_skipping plugin for details. + + :kwarg bool allow_module_level: allows this function to be called at + module level, skipping the rest of the module. Default to False. """ __tracebackhide__ = True - raise Skipped(msg=msg) + allow_module_level = kwargs.pop('allow_module_level', False) + if kwargs: + keys = [k for k in kwargs.keys()] + raise TypeError('unexpected keyworkd arguments: {}'.format(keys)) + raise Skipped(msg=msg, allow_module_level=allow_module_level) skip.Exception = Skipped