Add allow_module_level kwarg to skip helper

This commit is contained in:
George Y. Kussumoto 2017-10-01 18:38:29 -03:00
parent d132c502e6
commit 79d3353081
1 changed files with 9 additions and 2 deletions

View File

@ -62,14 +62,21 @@ def exit(msg):
exit.Exception = Exit exit.Exception = Exit
def skip(msg=""): def skip(msg="", **kwargs):
""" skip an executing test with the given message. Note: it's usually """ 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 better to use the pytest.mark.skipif marker to declare a test to be
skipped under certain conditions like mismatching platforms or skipped under certain conditions like mismatching platforms or
dependencies. See the pytest_skipping plugin for details. 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 __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 skip.Exception = Skipped