New submission from Dmitry Andreychuk:
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.
----------
components: Library (Lib)
messages: 218321
nosy: and
priority: normal
severity: normal
status: open
title: mock calls don't propagate to parent (autospec)
type: behavior
versions: Python 3.3, Python 3.4
_______________________________________
Python tracker <[email protected]>
<http://bugs.python.org/issue21478>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com