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

MockObject.__eq__ behaviour causes problems when the mocks are used in lists. #59

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

Comments

@GoogleCodeExporter
Copy link

MockObject and MockAnything are just equal to any other mock that happens to 
have the same "replay_mode" and "expected_calls_queue". That creates problem 
when the mocks are used in sequences / collections / lists. For example, 
list.count() will probably give the wrong result as it will count all mock 
instances. 

Here is an example 

import mox

mocker = mox.Mox()
mock1 = mocker.CreateMockAnything(description="mock1 is unique")
mock2 = mocker.CreateMockAnything(description="mock2 is also unique")
print [mock1, mock2].count(mock1) #=> 2 but should be 1 


Wouldn't be better if __eq__ compared at least the attrs of the mocks? If they 
have a different set of mocked attributes they can't be "equal", right?

Original issue reported on code.google.com by ruben.la...@gmail.com on 12 Oct 2014 at 6:09

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