Is there a way to get the mock calls counted by call_count
in this example:
from mock import MagicMock
mock = MagicMock()
mock.get_query(arg=1).execute()
mock.get_query(arg=2).execute()
print('count:', mock.get_query.call_count)
print('calls:', mock.get_query.mock_calls)
Actual result:
count: 2
calls: [call(arg=1), call().execute(), call(arg=2), call().execute()]
Desired result:
count: 2
calls: [call(arg=1), call(arg=2)]
I understand mock_calls
. The documentation is quite clear:
mock_calls records all calls to the mock object, its methods, magic methods and return value mocks.
I'm wondering if there's an elegent way to filter mock_calls
. There's also method_calls
but it's still not it.