[New-bugs-announce] [issue17185] create_autospec

Chris Withers report at bugs.python.org
Mon Feb 11 23:31:40 CET 2013

New submission from Chris Withers:

Sticking an issue in at Michael's request...

Older versions of mock had a helper called mocksignature.
In newer versions, create_autospec replaces this, but doesn't get it right sometimes:

>>> from inspect import getargspec
>>> from mock import create_autospec
>>> def myfunc(x, y): pass
>>> getargspec(myfunc)
ArgSpec(args=['x', 'y'], varargs=None, keywords=None, defaults=None)
>>> getargspec(create_autospec(myfunc))
ArgSpec(args=[], varargs='args', keywords='kwargs', defaults=None)

mocksignature gets it right:

>>> from mock import mocksignature
>>> getargspec(mocksignature(myfunc))
ArgSpec(args=['x', 'y'], varargs=None, keywords=None, defaults=None)

assignee: michael.foord
messages: 181934
nosy: cjw296, michael.foord
priority: normal
severity: normal
status: open
title: create_autospec

Python tracker <report at bugs.python.org>

More information about the New-bugs-announce mailing list