mirror of
https://github.com/python/cpython.git
synced 2025-07-24 11:44:31 +00:00
bpo-37685: Fixed __eq__, __lt__ etc implementations in some classes. (GH-14952)
They now return NotImplemented for unsupported type of the other operand.
This commit is contained in:
parent
4c69be22df
commit
662db125cd
23 changed files with 1295 additions and 1150 deletions
|
@ -2358,12 +2358,10 @@ class _Call(tuple):
|
|||
|
||||
|
||||
def __eq__(self, other):
|
||||
if other is ANY:
|
||||
return True
|
||||
try:
|
||||
len_other = len(other)
|
||||
except TypeError:
|
||||
return False
|
||||
return NotImplemented
|
||||
|
||||
self_name = ''
|
||||
if len(self) == 2:
|
||||
|
|
|
@ -3,6 +3,7 @@ import re
|
|||
import sys
|
||||
import tempfile
|
||||
|
||||
from test.support import ALWAYS_EQ
|
||||
import unittest
|
||||
from unittest.test.testmock.support import is_instance
|
||||
from unittest import mock
|
||||
|
@ -322,6 +323,8 @@ class MockTest(unittest.TestCase):
|
|||
self.assertFalse(mm != mock.ANY)
|
||||
self.assertTrue(mock.ANY == mm)
|
||||
self.assertFalse(mock.ANY != mm)
|
||||
self.assertTrue(mm == ALWAYS_EQ)
|
||||
self.assertFalse(mm != ALWAYS_EQ)
|
||||
|
||||
call1 = mock.call(mock.MagicMock())
|
||||
call2 = mock.call(mock.ANY)
|
||||
|
@ -330,6 +333,11 @@ class MockTest(unittest.TestCase):
|
|||
self.assertTrue(call2 == call1)
|
||||
self.assertFalse(call2 != call1)
|
||||
|
||||
self.assertTrue(call1 == ALWAYS_EQ)
|
||||
self.assertFalse(call1 != ALWAYS_EQ)
|
||||
self.assertFalse(call1 == 1)
|
||||
self.assertTrue(call1 != 1)
|
||||
|
||||
|
||||
def test_assert_called_with(self):
|
||||
mock = Mock()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue