Skip to content

Wrap recorded calls on existing instance #3

@yalon

Description

@yalon

Instead of using the hybrid mock, allow the user to create his/her own instance so the constructor code will run, and then wrap the object with the recorded calls.

Something in the lines of:

mock_template = forge.create_mock_template(MyClass)
mock_template.foo().and_returns(42)

forge.replay()

my_obj = MyClass(my_var=1, another_var='foo')
mock_template.wrap(my_obj)

my_obj.foo() # return 42
my_obj.bar() # call the original function

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions