diff options
author | Benjamin Peterson <benjamin@python.org> | 2008-10-16 19:34:46 (GMT) |
---|---|---|
committer | Benjamin Peterson <benjamin@python.org> | 2008-10-16 19:34:46 (GMT) |
commit | 60192084c405292f874d886eed05ed83614d20c4 (patch) | |
tree | 390e2ac0930a866fb1a97d35b469109f09df3ecc /Lib/test/test_descr.py | |
parent | aaebe1c11d0eccc067cb6e5bb4e28543441fd2df (diff) | |
download | cpython-60192084c405292f874d886eed05ed83614d20c4.zip cpython-60192084c405292f874d886eed05ed83614d20c4.tar.gz cpython-60192084c405292f874d886eed05ed83614d20c4.tar.bz2 |
remove some more references to __cmp__ #1717
Diffstat (limited to 'Lib/test/test_descr.py')
-rw-r--r-- | Lib/test/test_descr.py | 59 |
1 files changed, 13 insertions, 46 deletions
diff --git a/Lib/test/test_descr.py b/Lib/test/test_descr.py index 3c0bae0..85df9dc 100644 --- a/Lib/test/test_descr.py +++ b/Lib/test/test_descr.py @@ -1566,7 +1566,7 @@ order (MRO) for bases """ for i in range(10): self.assert_(i in d1) self.assertFalse(10 in d1) - # Test overridden behavior for static classes + # Test overridden behavior class Proxy(object): def __init__(self, x): self.x = x @@ -1578,8 +1578,14 @@ order (MRO) for bases """ return self.x == other def __ne__(self, other): return self.x != other - def __cmp__(self, other): - return cmp(self.x, other.x) + def __ge__(self, other): + return self.x >= other + def __gt__(self, other): + return self.x > other + def __le__(self, other): + return self.x <= other + def __lt__(self, other): + return self.x < other def __str__(self): return "Proxy:%s" % self.x def __repr__(self): @@ -1596,9 +1602,10 @@ order (MRO) for bases """ self.assertNotEqual(p0, p1) self.assert_(not p0 != p0) self.assertEqual(not p0, p1) - self.assertEqual(cmp(p0, p1), -1) - self.assertEqual(cmp(p0, p0), 0) - self.assertEqual(cmp(p0, p_1), 1) + self.assert_(p0 < p1) + self.assert_(p0 <= p1) + self.assert_(p1 > p0) + self.assert_(p1 >= p0) self.assertEqual(str(p0), "Proxy:0") self.assertEqual(repr(p0), "Proxy(0)") p10 = Proxy(range(10)) @@ -1606,46 +1613,6 @@ order (MRO) for bases """ for i in range(10): self.assert_(i in p10) self.assertFalse(10 in p10) - # Test overridden behavior for dynamic classes - class DProxy(object): - def __init__(self, x): - self.x = x - def __bool__(self): - return not not self.x - def __hash__(self): - return hash(self.x) - def __eq__(self, other): - return self.x == other - def __ne__(self, other): - return self.x != other - def __cmp__(self, other): - return cmp(self.x, other.x) - def __str__(self): - return "DProxy:%s" % self.x - def __repr__(self): - return "DProxy(%r)" % self.x - def __contains__(self, value): - return value in self.x - p0 = DProxy(0) - p1 = DProxy(1) - p_1 = DProxy(-1) - self.assertFalse(p0) - self.assert_(not not p1) - self.assertEqual(hash(p0), hash(0)) - self.assertEqual(p0, p0) - self.assertNotEqual(p0, p1) - self.assertNotEqual(not p0, p0) - self.assertEqual(not p0, p1) - self.assertEqual(cmp(p0, p1), -1) - self.assertEqual(cmp(p0, p0), 0) - self.assertEqual(cmp(p0, p_1), 1) - self.assertEqual(str(p0), "DProxy:0") - self.assertEqual(repr(p0), "DProxy(0)") - p10 = DProxy(range(10)) - self.assertFalse(-1 in p10) - for i in range(10): - self.assert_(i in p10) - self.assertFalse(10 in p10) ## # Safety test for __cmp__ ## def unsafecmp(a, b): |