kaste / mockito-python

Mockito is a spying framework
MIT License
123 stars 12 forks source link

Fix: Only record captured arguments in execution phase #50

Closed kaste closed 2 years ago

kaste commented 2 years ago

Fixes #49

Our captor recorded its use as a by product of successfully using (actually: asking) matches. This leads to wrong behavior as soon as the captor matches but the call signature as a whole still fails.

For example consider when(foo).bar(captor(), 11). Here the "any" captor always matches even when the second argument, the literal "11", fails.

Make the side-effect explicit by implementing a new capture_arguments which is called if the whole call signature matches.