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 @@ -1769,14 +1769,18 @@ def __eq__(other):
17691769 ret_val = self .__eq__ ._mock_return_value
17701770 if ret_val is not DEFAULT :
17711771 return ret_val
1772- return self is other
1772+ if self is other :
1773+ return True
1774+ return NotImplemented
17731775 return __eq__
17741776
17751777def _get_ne (self ):
17761778 def __ne__ (other ):
17771779 if self .__ne__ ._mock_return_value is not DEFAULT :
17781780 return DEFAULT
1779- return self is not other
1781+ if self is other :
1782+ return False
1783+ return NotImplemented
17801784 return __ne__
17811785
17821786def _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 @@ -47,6 +47,8 @@ Core and Builtins
4747Library
4848-------
4949
50+ - Issue #28735: Fixed the comparison of mock.MagickMock with mock.ANY.
51+
5052- Issue #29316: Restore the provisional status of typing module, add
5153 corresponding note to documentation. Patch by Ivan L.
5254
You can’t perform that action at this time.
0 commit comments