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 @@ -1749,14 +1749,18 @@ def __eq__(other):
1749
1749
ret_val = self .__eq__ ._mock_return_value
1750
1750
if ret_val is not DEFAULT :
1751
1751
return ret_val
1752
- return self is other
1752
+ if self is other :
1753
+ return True
1754
+ return NotImplemented
1753
1755
return __eq__
1754
1756
1755
1757
def _get_ne (self ):
1756
1758
def __ne__ (other ):
1757
1759
if self .__ne__ ._mock_return_value is not DEFAULT :
1758
1760
return DEFAULT
1759
- return self is not other
1761
+ if self is other :
1762
+ return False
1763
+ return NotImplemented
1760
1764
return __ne__
1761
1765
1762
1766
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 @@ -13,6 +13,8 @@ Core and Builtins
13
13
Library
14
14
-------
15
15
16
+ - Issue #28735: Fixed the comparison of mock.MagickMock with mock.ANY.
17
+
16
18
- Issue #29011: Fix an important omission by adding Deque to the typing module.
17
19
18
20
- Issue #29219: Fixed infinite recursion in the repr of uninitialized
You can’t perform that action at this time.
0 commit comments