Author xtreak
Recipients ElizabethU, xtreak
Date 2019-07-11.05:46:58
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
Thanks for the report. Can you please add an example without Django or other dependencies so that I can try reproducing it? I am trying out the below program from the report where Foo has overridden __eq__ to return False if the other object being compared is not a Foo object. In the next statements ANY == Foo() returns True since the left side's object.__eq__ is used which in this case is ANY.__eq__ as you have noted in the original report. 

When list of call objects are compared there is also a code comment about this in the tuple comparison  of args and kwargs such that ANY is placed on the left side [0] so that ANY.__eq__ is used. A pure python example and traceback if any would help here.

from unittest.mock import call, ANY, Mock

class Foo:

    def __eq__(self, other):
        if not isinstance(other, Foo):
            return False
        return True

m = Mock()
obj = Foo()
m(obj, 1)
m.assert_has_calls([call(ANY, 1)])

print(ANY == Foo()) # ANY.__eq__ is called
print(Foo() == ANY) # Foo().__eq__ is called

Is the report more about the below case where position of call objects returns different values?

print(call(ANY, 1) == call(obj, 1)) # False
print(call(obj, 1) == call(ANY, 1)) # True

Date User Action Args
2019-07-11 05:46:59xtreaksetrecipients: + xtreak, ElizabethU
2019-07-11 05:46:59xtreaksetmessageid: <>
2019-07-11 05:46:59xtreaklinkissue37555 messages
2019-07-11 05:46:58xtreakcreate