summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_long.py
diff options
context:
space:
mode:
authorMark Dickinson <dickinsm@gmail.com>2009-01-27 18:17:45 (GMT)
committerMark Dickinson <dickinsm@gmail.com>2009-01-27 18:17:45 (GMT)
commita56c467ac39ab1a6a2e9dc2fa41a9f573f989839 (patch)
treef65fc7d2a4359328f10c1dd9122a692e78e71e8a /Lib/test/test_long.py
parent191e850053128f726d6562e1d8306dfe5e4aa8aa (diff)
downloadcpython-a56c467ac39ab1a6a2e9dc2fa41a9f573f989839.zip
cpython-a56c467ac39ab1a6a2e9dc2fa41a9f573f989839.tar.gz
cpython-a56c467ac39ab1a6a2e9dc2fa41a9f573f989839.tar.bz2
Issue #1717: Remove cmp. Stage 1: remove all uses of cmp and __cmp__ from
the standard library and tests.
Diffstat (limited to 'Lib/test/test_long.py')
-rw-r--r--Lib/test/test_long.py7
1 files changed, 4 insertions, 3 deletions
diff --git a/Lib/test/test_long.py b/Lib/test/test_long.py
index c1f8b5c..2acb3fa 100644
--- a/Lib/test/test_long.py
+++ b/Lib/test/test_long.py
@@ -697,7 +697,8 @@ class LongTest(unittest.TestCase):
def _cmp__(self, other):
if not isinstance(other, Rat):
other = Rat(other)
- return cmp(self.n * other.d, self.d * other.n)
+ x, y = self.n * other.d, self.d * other.n
+ return (x > y) - (x < y)
def __eq__(self, other):
return self._cmp__(other) == 0
def __ne__(self, other):
@@ -727,8 +728,8 @@ class LongTest(unittest.TestCase):
Rx = Rat(x)
for y in cases:
Ry = Rat(y)
- Rcmp = cmp(Rx, Ry)
- xycmp = cmp(x, y)
+ Rcmp = (Rx > Ry) - (Rx < Ry)
+ xycmp = (x > y) - (x < y)
eq(Rcmp, xycmp, Frm("%r %r %d %d", x, y, Rcmp, xycmp))
eq(x == y, Rcmp == 0, Frm("%r == %r %d", x, y, Rcmp))
eq(x != y, Rcmp != 0, Frm("%r != %r %d", x, y, Rcmp))