pyforge icon indicating copy to clipboard operation
pyforge copied to clipboard

Wrap recorded calls on existing instance

Open yalon opened this issue 12 years ago • 1 comments

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

yalon avatar Aug 22 '12 13:08 yalon

Isn't "MockWrapper" or "MockProxy" a better name?

vmalloc avatar Dec 09 '12 15:12 vmalloc