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

Group multiple_times() doesn't play well with with_side_effects() #29

Open
ivancrneto opened this issue Jan 6, 2024 · 0 comments
Open
Labels
bug Something isn't working good first issue Good for newcomers

Comments

@ivancrneto
Copy link
Owner

Bug situation using multiple_times() combined with wth_side_effects() but not
and_return. 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 test_multiple_times_with_side_effects(self):
        mock = mox.Mox()

        mock_obj = mock.create_mock_anything()
        mock_obj.open()
        mock_obj.method(mox.is_a(int)).multiple_times().with_side_effects(lambda x: x + 1)
        mock_obj.close()
        mock.replay_all() 

        mock_obj.open() 
        actual_one = mock_obj.method(1)
        actual_three = mock_obj.method(3)
        mock_obj.close()

        assert actual_one == 2
        assert actual_three == 4

        mock.verify_all()
@ivancrneto ivancrneto added bug Something isn't working good first issue Good for newcomers labels Jan 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

1 participant