diff -r 37a07cee5969 Lib/unittest/mock.py --- a/Lib/unittest/mock.py Sat Dec 05 17:05:23 2015 -0800 +++ b/Lib/unittest/mock.py Mon Feb 08 10:57:51 2016 +0000 @@ -2026,6 +2026,9 @@ return (other_args, other_kwargs) == (self_args, self_kwargs) + __ne__ = object.__ne__ + + def __call__(self, *args, **kwargs): if self.name is None: return _Call(('', args, kwargs), name='()') diff -r 37a07cee5969 Lib/unittest/test/testmock/testmock.py --- a/Lib/unittest/test/testmock/testmock.py Sat Dec 05 17:05:23 2015 -0800 +++ b/Lib/unittest/test/testmock/testmock.py Mon Feb 08 10:57:51 2016 +0000 @@ -304,6 +304,17 @@ # an exception. See issue 24857. self.assertFalse(mock.call_args == "a long sequence") + + def test_calls_equal_with_any(self): + call1 = mock.call(mock.MagicMock()) + call2 = mock.call(mock.ANY) + + # Check that equality and non-equality is consistent even when + # comparing with mock.ANY + self.assertTrue(call1 == call2) + self.assertFalse(call1 != call2) + + def test_assert_called_with(self): mock = Mock() mock() @@ -319,6 +330,12 @@ mock.assert_called_with(1, 2, 3, a='fish', b='nothing') + def test_assert_called_with_any(self): + m = MagicMock() + m(MagicMock()) + m.assert_called_with(mock.ANY) + + def test_assert_called_with_function_spec(self): def f(a, b, c, d=None): pass