[TIP] autospec and wraps interaction

Jonathan Chien jchien10 at gmail.com
Wed Nov 18 15:43:37 PST 2015


I get the following behavior with autospec and wraps.
>>> from foo import dummy
>>> p1 = mock.patch('foo.dummy', wraps=dummy)
>>> m1 = z1.start()
>>> m1
<MagicMock name='dummy' id='4429382744'>
>>> m1()
foo
>>> p2 = mock.patch('foo.dummy', autospec=True, wraps=dummy)
>>> m2 = p2.start()
>>> m2
<function dummy at 0x1080149b8>
>>> m2()
<MagicMock name='dummy()' id='4429216280'>

Is this expected behavior? It seems to me like autospec shouldn't change
the behavior of wraps.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.idyll.org/pipermail/testing-in-python/attachments/20151118/932c886f/attachment.htm>


More information about the testing-in-python mailing list