Wednesday, April 18, 2012

Mock only a subset of all calls to a method.

I would like to mock only a sub set of calls to a method using the Mock module. So,



fubar = Fubar()
fubar.myMethod = Mock()
funar.myMethod.return_value = [fubar.myMethod(), 'MyMOck', fubar.MyMethod]


would call the read method myMethod the first and third time but would call the mocked method on the second call.



Is this possible? If so, how? If not, why not?





No comments:

Post a Comment