This repository was archived by the owner on Feb 13, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 3 files changed +22
-5
lines changed
Expand file tree Collapse file tree 3 files changed +22
-5
lines changed Original file line number Diff line number Diff line change @@ -1765,14 +1765,18 @@ def __eq__(other):
17651765 ret_val = self .__eq__ ._mock_return_value
17661766 if ret_val is not DEFAULT :
17671767 return ret_val
1768- return self is other
1768+ if self is other :
1769+ return True
1770+ return NotImplemented
17691771 return __eq__
17701772
17711773def _get_ne (self ):
17721774 def __ne__ (other ):
17731775 if self .__ne__ ._mock_return_value is not DEFAULT :
17741776 return DEFAULT
1775- return self is not other
1777+ if self is other :
1778+ return False
1779+ return NotImplemented
17761780 return __ne__
17771781
17781782def _get_iter (self ):
Original file line number Diff line number Diff line change @@ -306,13 +306,24 @@ def test_call_args_comparison(self):
306306
307307
308308 def test_calls_equal_with_any (self ):
309- call1 = mock .call (mock .MagicMock ())
310- call2 = mock .call (mock .ANY )
311-
312309 # Check that equality and non-equality is consistent even when
313310 # comparing with mock.ANY
311+ mm = mock .MagicMock ()
312+ self .assertTrue (mm == mm )
313+ self .assertFalse (mm != mm )
314+ self .assertFalse (mm == mock .MagicMock ())
315+ self .assertTrue (mm != mock .MagicMock ())
316+ self .assertTrue (mm == mock .ANY )
317+ self .assertFalse (mm != mock .ANY )
318+ self .assertTrue (mock .ANY == mm )
319+ self .assertFalse (mock .ANY != mm )
320+
321+ call1 = mock .call (mock .MagicMock ())
322+ call2 = mock .call (mock .ANY )
314323 self .assertTrue (call1 == call2 )
315324 self .assertFalse (call1 != call2 )
325+ self .assertTrue (call2 == call1 )
326+ self .assertFalse (call2 != call1 )
316327
317328
318329 def test_assert_called_with (self ):
Original file line number Diff line number Diff line change @@ -215,6 +215,8 @@ Core and Builtins
215215Library
216216-------
217217
218+ - Issue #28735: Fixed the comparison of mock.MagickMock with mock.ANY.
219+
218220- Issue #29197: Removed deprecated function ntpath.splitunc().
219221
220222- Issue #29210: Removed support of deprecated argument "exclude" in
You can’t perform that action at this time.
0 commit comments