
pymox - issue #52
Patch for /trunk/mox.py - Bug fix for MultipleTimes().WithSideEffect()
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()
- mox.py.patch 692
Status: New
Labels:
Type-Patch