def skip_because(*args, **kwargs):
"""A decorator useful to skip tests hitting known bugs
@param bug: bug number causing the test to skip
@param condition: optional condition to be True for the skip to have place
@param interface: skip the test if it is the same as self._interface
"""
def decorator(f):
@functools.wraps(f)
def wrapper(self, *func_args, **func_kwargs):
skip = False
if "condition" in kwargs:
if kwargs["condition"] is True:
skip = True
elif "interface" in kwargs:
if kwargs["interface"] == self._interface:
skip = True
else:
skip = True
if "bug" in kwargs and skip is True:
msg = "Skipped until Bug: %s is resolved." % kwargs["bug"]
raise testtools.TestCase.skipException(msg)
return f(self, *func_args, **func_kwargs)
return wrapper
return decorator
评论列表
文章目录