Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Patch for /trunk/mox.py - Bug fix for MultipleTimes().WithSideEffect() #52

Open
GoogleCodeExporter opened this issue Mar 19, 2015 · 0 comments

Comments

@GoogleCodeExporter
Copy link

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()

Original issue reported on code.google.com by [email protected] on 12 Nov 2012 at 4:55

Attachments:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant