Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replacement call on callable Fake may be applied to expected methods too #10

Open
quantoid opened this issue Feb 28, 2019 · 0 comments
Open

Comments

@quantoid
Copy link

quantoid commented Feb 28, 2019

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.

@quantoid 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant