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
def dummy():
pass
example = Fake("Example")
example.expects("something").returns(123)
example.expects_call().calls(dummy)
Surprisingly, dummy() gets called when example.something() is called. This is because fudge.Call.__call__() finds a replacement on example.something and calls it, but then discards the return value and uses the return value declared in the expectations (123 in this case).
Not sure how the dummy replacement call finds its way onto example.something. The workaround is to use expects_call first before any expects or provides calls.
This can result in code being called more times than you were expecting.
The text was updated successfully, but these errors were encountered:
quantoid
changed the title
Replacement call on Fake will be applied to expected methods too
Replacement call on callable Fake may be applied to expected methods too
Feb 28, 2019
Consider a callable Fake with a single method:
Surprisingly,
dummy()
gets called whenexample.something()
is called. This is becausefudge.Call.__call__()
finds a replacement onexample.something
and calls it, but then discards the return value and uses the return value declared in the expectations (123 in this case).Not sure how the
dummy
replacement call finds its way ontoexample.something
. The workaround is to useexpects_call
first before anyexpects
orprovides
calls.This can result in code being called more times than you were expecting.
The text was updated successfully, but these errors were encountered: