pyforge
pyforge copied to clipboard
Wrap recorded calls on existing instance
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
Isn't "MockWrapper" or "MockProxy" a better name?