unit testing - When using python mox mock objects is there any way to avoid all of them being equal (as in __eq__)? -
I am facing some problems which are equal to all the counterfeit masks of any class, In the example of the code given below, you can see that the count is wrong because it thinks that all socks are the same: After the It seems that the implementation of Many additional implications when mocks You have to add some calls to the fake method to make socks in the eyes of == ,
__ eq __ expressions though they are different objects (at least
mock1 mock2 returns
False ). Is there any way to stop that behavior?
import mox class MyClass (object): Passed real1 = MyClass () real2 = MyClass () listreal = (real1, real2) joke = 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 # This is true mock1 is mock2 # false listmock.count (mock1) # 2
__ eq __ for
mox.mockAnything and
mox.MockObject simply
replay_mode and
expected_calls_queue therefore compares any duplicate object that is expected of the same call is actually "equal" .
list.remove () , etc. That is used in
__ eq __ .
Comments
Post a Comment