You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
from callee.general import Captor
from mock import Mock
mock = Mock()
mock(1)
captor = Captor()
mock.assert_called_with(captor)
assert 1 == captor.value # This is ok!
mock(2)
mock.assert_called_with(captor) # Fails with ValueError: a value has already been captured
This is somewhat inconsistent with how Mock::assert_called_with works. For example:
mock = Mock()
mock(1)
mock(2)
mock(3)
mock.assert_called_with(3) # This is ok!
There are multiple ways to deal with this.
Allow Captor to be created with an allow_multiple_captures parameter and set the value to the last captured argument
Currently the following will fail
This is somewhat inconsistent with how
Mock::assert_called_with works
. For example:There are multiple ways to deal with this.
Captor
to be created with anallow_multiple_captures
parameter and set the value to the last captured argumentCaptor
to match multiple arguments and save them in a listMultiCaptor
Captor that will collect all matches for a given argumentThe text was updated successfully, but these errors were encountered: