I'm experiencing some problems derived from the fact than several all mox Mock object of a given class seem to be equal in the ==
,__eq__
sense although they are different objects (at least mock1 is mock2
returns False
). is there any way to prevent that behaviour?
In the code example below you can see that the count is wrong because it thinks all the mocks are equal:
import mox
class MyClass(object):
pass
real1 = MyClass()
real2 = MyClass()
listreal = (real1, real2)
mocker = mox.Mox()
mock1 = mocker.CreateMock(MyClass)
mock2 = mocker.CreateMock(MyClass)
listmock = (mock1, mock2)
real1 == real2 # False
real1 is real2 # False
listreal.count(real1) # 1
mock1 == mock2 # True
mock1 is mock2 # False
listmock.count(mock1) # 2