[issue37555] _CallList.__contains__ doesn't always respect ANY.
Paul Ganssle
report at bugs.python.org
Mon Jul 15 10:20:09 EDT 2019
Paul Ganssle <p.ganssle at gmail.com> added the comment:
Maybe I am missing something, but while it is true that DjangoModel is doing the wrong thing by returning False instead of NotImplemented, the `ANY` sentinel is supposed to match *anything*, not just things that compare equal to it, right? I would expect this to work, for example:
class EqualsNothing:
def __eq__(self, other):
return False
m = Mock(spec_set=EqualsNothing)
obj = EqualsNothing()
m(obj)
m.assert_has_calls([call(ANY)])
In that example, it is deliberate that EqualsNothing returns False for any type, but ANY should still match it. I think maybe the solution here is to special-case the matching with ANY so the criterion for a call matching would be `y is ANY or x == y`.
----------
nosy: +p-ganssle
_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue37555>
_______________________________________
More information about the Python-bugs-list
mailing list