[TIP] create_autospec not as good as mocksignature

Chris Withers chris at simplistix.co.uk
Tue Feb 5 07:23:28 PST 2013

Hi Michael,

I see mocksignature is no more, which is a shame when you use getargspec:

 >>> 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)

That can be surprisingly annoying ;-)

mocksignature gets it right:

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

Any chance create_autospec could be fixed or mocksignature re-instated?



Simplistix - Content Management, Batch Processing & Python Consulting
             - http://www.simplistix.co.uk

More information about the testing-in-python mailing list