Status: New
Owner: ----
Labels: Type-Patch
New issue 52 by
kma...@google.com: Patch for /trunk/mox.py - Bug fix for
MultipleTimes().WithSideEffect()
http://code.google.com/p/pymox/issues/detail?id=52
Bug situation using MultipleTimes() combined with WithSideEffects() but not
AndReturn. The return value from the first call to the side effect method
will become the return value for all subsequent calls to the MockMethod.
Unit test which illustrates the current bug:
def testMultipleTimesWithSideEffects(self):
"""Test MultipleTimes with side effects."""
mock_obj = self.mox.CreateMockAnything()
mock_obj.Open()
mock_obj.Method(mox.IsA(int)).MultipleTimes().WithSideEffects(
lambda x: x + 1)
mock_obj.Close()
self.mox.ReplayAll()
mock_obj.Open()
actual_one = mock_obj.Method(1)
actual_three = mock_obj.Method(3)
mock_obj.Close()
self.assertEquals(2, actual_one)
self.assertEquals(4, actual_three)
self.mox.VerifyAll()
Attachments:
mox.py.patch 692 bytes