Author and
Recipients and
Date 2014-05-12.12:56:34
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1399899394.81.0.714942512868.issue21478@psf.upfronthosting.co.za>
In-reply-to
Content
Calls to autospecced mock functions are not recorded to mock_calls list of parent mock. This only happens if autospec is used and the original object is a function.

Example:

import unittest.mock as mock

def foo():
    pass

parent = mock.Mock()
parent.child = mock.create_autospec(foo)
parent.child()
print(parent.mock_calls)


Output:
[]

Expected output:
[call.child()]

It works fine if foo function is substituted with a class.

Initially I came across this problem with patch() and attach_mock() but I simplified it for the demonstration.
History
Date User Action Args
2014-05-12 12:56:34andsetrecipients: + and
2014-05-12 12:56:34andsetmessageid: <1399899394.81.0.714942512868.issue21478@psf.upfronthosting.co.za>
2014-05-12 12:56:34andlinkissue21478 messages
2014-05-12 12:56:34andcreate