base.py 文件源码

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

项目:sinon 作者: note35 项目源码 文件源码
def __new__(cls, obj=None, prop=None, func=None):
        """
        Constructor of SinonBase
        It will new true base but return a proxy of weakref and store it in _queue
        Args:
            obj: None / function / instance method / module / class
                Inspected target
            prop: None / string
                Inspected target when obj contains callable things
            func: function / instance method
                ONLY used by stub, it will replace original target
        Return:
            weakref
        """
        new = super(SinonBase, cls).__new__(cls)
        if func:
            new.__init__(obj, prop, func)
        else:
            new.__init__(obj, prop)
        cls._queue.append(new)
        return weakref.proxy(new)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号