Skip to content

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

@quantoid

Description

@quantoid

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions