def decorate_func_or_method_or_class(decorator):
"""Applies a decorator to a function, method, or all methods of a class.
This is a decorator that is applied to a decorator to allow a
function/method decorator to be applied to a class and have it act on all
test methods of the class.
"""
def decorate(func_or_class):
if inspect.isclass(func_or_class):
return decorate_all_test_methods(decorator)(func_or_class)
elif inspect.isfunction(func_or_class):
return decorator(func_or_class)
else:
assert False, 'Target of decorator must be function or class'
return decorate
评论列表
文章目录