base.py 文件源码

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

项目:sinon 作者: note35 项目源码 文件源码
def init(scope):
    """
    Copy all values of scope into the class SinonGlobals
    Args:
        scope (eg. locals() or globals())
    Return:
        SinonGlobals instance
    """
    class SinonGlobals(object): #pylint: disable=too-few-public-methods
        """
        A fully empty class
        External can push the whole `scope` into this class through global function init()
        """
        pass

    global CPSCOPE #pylint: disable=global-statement
    CPSCOPE = SinonGlobals()
    funcs = [obj for obj in scope.values() if isinstance(obj, FunctionType)]
    for func in funcs:
        setattr(CPSCOPE, func.__name__, func)
    return CPSCOPE
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号