def signatures_match(cls, orig, stubbed, ignore_self=False):
if six.PY2:
orig_arguments = inspect.getargspec(orig)
stub_arguments = inspect.getargspec(stubbed)
else:
orig_arguments = inspect.getfullargspec(orig)
stub_arguments = inspect.getfullargspec(stubbed)
if ignore_self:
if 'self' in orig_arguments.args: orig_arguments.args.remove('self')
if 'self' in stub_arguments.args: stub_arguments.args.remove('self')
assert orig_arguments == stub_arguments, \
'signature mismatch: %s%s does not match %s%s' % \
(stubbed, inspect.formatargspec(*stub_arguments),
orig, inspect.formatargspec(*orig_arguments))
return False
#------------------------------------------------[ Impostor ]
评论列表
文章目录