mirror of
https://github.com/python/cpython.git
synced 2025-08-30 21:48:47 +00:00
Issue #1717: Remove cmp. Stage 1: remove all uses of cmp and __cmp__ from
the standard library and tests.
This commit is contained in:
parent
191e850053
commit
a56c467ac3
32 changed files with 210 additions and 216 deletions
|
@ -56,31 +56,16 @@ class TestContains(unittest.TestCase):
|
|||
This class is designed to make sure that the contains code
|
||||
works when the list is modified during the check.
|
||||
"""
|
||||
aList = range(15)
|
||||
def __cmp__(self, other):
|
||||
aList = list(range(15))
|
||||
def __eq__(self, other):
|
||||
if other == 12:
|
||||
self.aList.remove(12)
|
||||
self.aList.remove(13)
|
||||
self.aList.remove(14)
|
||||
return 1
|
||||
return 0
|
||||
|
||||
self.assert_(Deviant1() not in Deviant1.aList)
|
||||
|
||||
class Deviant2:
|
||||
"""Behaves strangely when compared
|
||||
|
||||
This class raises an exception during comparison. That in
|
||||
turn causes the comparison to fail with a TypeError.
|
||||
"""
|
||||
def __cmp__(self, other):
|
||||
if other == 4:
|
||||
raise RuntimeError("gotcha")
|
||||
|
||||
try:
|
||||
self.assert_(Deviant2() not in a)
|
||||
except TypeError:
|
||||
pass
|
||||
|
||||
def test_nonreflexive(self):
|
||||
# containment and equality tests involving elements that are
|
||||
# not necessarily equal to themselves
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue