[TIP] create_autospec not as good as mocksignature

Michael Foord michael at voidspace.org.uk
Sun Feb 10 13:52:22 PST 2013


On 5 Feb 2013, at 15:23, Chris Withers <chris at simplistix.co.uk> wrote:

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

File an issue about it. 

Michael

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


--
http://www.voidspace.org.uk/


May you do good and not evil
May you find forgiveness for yourself and forgive others
May you share freely, never taking more than you give.
-- the sqlite blessing 
http://www.sqlite.org/different.html








More information about the testing-in-python mailing list