testing.py 文件源码

python
阅读 28 收藏 0 点赞 0 评论 0

项目:qcore 作者: quora 项目源码 文件源码
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
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号