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):
1769
1769
ret_val = self .__eq__ ._mock_return_value
1770
1770
if ret_val is not DEFAULT :
1771
1771
return ret_val
1772
- return self is other
1772
+ if self is other :
1773
+ return True
1774
+ return NotImplemented
1773
1775
return __eq__
1774
1776
1775
1777
def _get_ne (self ):
1776
1778
def __ne__ (other ):
1777
1779
if self .__ne__ ._mock_return_value is not DEFAULT :
1778
1780
return DEFAULT
1779
- return self is not other
1781
+ if self is other :
1782
+ return False
1783
+ return NotImplemented
1780
1784
return __ne__
1781
1785
1782
1786
def _get_iter (self ):
Original file line number Diff line number Diff line change @@ -306,13 +306,24 @@ def test_call_args_comparison(self):
306
306
307
307
308
308
def test_calls_equal_with_any (self ):
309
- call1 = mock .call (mock .MagicMock ())
310
- call2 = mock .call (mock .ANY )
311
-
312
309
# Check that equality and non-equality is consistent even when
313
310
# 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 )
314
323
self .assertTrue (call1 == call2 )
315
324
self .assertFalse (call1 != call2 )
325
+ self .assertTrue (call2 == call1 )
326
+ self .assertFalse (call2 != call1 )
316
327
317
328
318
329
def test_assert_called_with (self ):
Original file line number Diff line number Diff line change @@ -47,6 +47,8 @@ Core and Builtins
47
47
Library
48
48
-------
49
49
50
+ - Issue #28735: Fixed the comparison of mock.MagickMock with mock.ANY.
51
+
50
52
- Issue #29316: Restore the provisional status of typing module, add
51
53
corresponding note to documentation. Patch by Ivan L.
52
54
You can’t perform that action at this time.
0 commit comments