Consider a callable Fake with a single method:
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.
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.somethingand 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
dummyreplacement call finds its way ontoexample.something. The workaround is to useexpects_callfirst before anyexpectsorprovidescalls.This can result in code being called more times than you were expecting.