summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_descr.py
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/test/test_descr.py')
-rw-r--r--Lib/test/test_descr.py40
1 files changed, 11 insertions, 29 deletions
diff --git a/Lib/test/test_descr.py b/Lib/test/test_descr.py
index 1020740..9cedf44 100644
--- a/Lib/test/test_descr.py
+++ b/Lib/test/test_descr.py
@@ -172,7 +172,6 @@ class OperatorsTest(unittest.TestCase):
def test_dicts(self):
# Testing dict operations...
- ## self.binop_test({1:2}, {2:1}, -1, "cmp(a,b)", "__cmp__")
self.binop_test({1:2,3:4}, 1, 1, "b in a", "__contains__")
self.binop_test({1:2,3:4}, 2, 0, "b in a", "__contains__")
self.binop_test({1:2,3:4}, 1, 2, "a[b]", "__getitem__")
@@ -332,8 +331,6 @@ class OperatorsTest(unittest.TestCase):
# This is an ugly hack:
copy._deepcopy_dispatch[spam.spamdict] = spamdict
- ## self.binop_test(spamdict({1:2}), spamdict({2:1}), -1, "cmp(a,b)",
- ## "__cmp__")
self.binop_test(spamdict({1:2,3:4}), 1, 1, "b in a", "__contains__")
self.binop_test(spamdict({1:2,3:4}), 2, 0, "b in a", "__contains__")
self.binop_test(spamdict({1:2,3:4}), 1, 2, "a[b]", "__getitem__")
@@ -1004,8 +1001,8 @@ order (MRO) for bases """
# Test lookup leaks [SF bug 572567]
import sys,gc
class G(object):
- def __cmp__(self, other):
- return 0
+ def __eq__(self, other):
+ return 1
g = G()
orig_objects = len(gc.get_objects())
for i in range(10):
@@ -1525,7 +1522,6 @@ order (MRO) for bases """
self.assertNotEqual(id(c1), id(c2))
hash(c1)
hash(c2)
- ## self.assertEqual(cmp(c1, c2), cmp(id(c1), id(c2)))
self.assertEqual(c1, c1)
self.assert_(c1 != c2)
self.assert_(not c1 != c1)
@@ -1549,7 +1545,6 @@ order (MRO) for bases """
self.assertNotEqual(id(d1), id(d2))
hash(d1)
hash(d2)
- ## self.assertEqual(cmp(d1, d2), cmp(id(d1), id(d2)))
self.assertEqual(d1, d1)
self.assertNotEqual(d1, d2)
self.assert_(not d1 != d1)
@@ -1610,23 +1605,6 @@ order (MRO) for bases """
self.assert_(i in p10)
self.assertFalse(10 in p10)
- ## # Safety test for __cmp__
- ## def unsafecmp(a, b):
- ## try:
- ## a.__class__.__cmp__(a, b)
- ## except TypeError:
- ## pass
- ## else:
- ## self.fail("shouldn't allow %s.__cmp__(%r, %r)" % (
- ## a.__class__, a, b))
- ##
- ## unsafecmp("123", "123")
- ## unsafecmp("123", "123")
- ## unsafecmp(1, 1.0)
- ## unsafecmp(1.0, 1)
- ## unsafecmp(1, 1)
- ## unsafecmp(1, 1)
-
def test_weakrefs(self):
# Testing weak references...
import weakref
@@ -2538,12 +2516,16 @@ order (MRO) for bases """
c = {1: c1, 2: c2, 3: c3}
for x in 1, 2, 3:
for y in 1, 2, 3:
- ## self.assert_(cmp(c[x], c[y]) == cmp(x, y), "x=%d, y=%d" % (x, y))
for op in "<", "<=", "==", "!=", ">", ">=":
- self.assert_(eval("c[x] %s c[y]" % op) == eval("x %s y" % op),
- "x=%d, y=%d" % (x, y))
- ## self.assert_(cmp(c[x], y) == cmp(x, y), "x=%d, y=%d" % (x, y))
- ## self.assert_(cmp(x, c[y]) == cmp(x, y), "x=%d, y=%d" % (x, y))
+ self.assert_(eval("c[x] %s c[y]" % op) ==
+ eval("x %s y" % op),
+ "x=%d, y=%d" % (x, y))
+ self.assert_(eval("c[x] %s y" % op) ==
+ eval("x %s y" % op),
+ "x=%d, y=%d" % (x, y))
+ self.assert_(eval("x %s c[y]" % op) ==
+ eval("x %s y" % op),
+ "x=%d, y=%d" % (x, y))
def test_rich_comparisons(self):
# Testing rich comparisons...