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)
评论列表
文章目录