Mercurial > cpython-lru_cache-weakref
diff Lib/test/test_long.py @ 51122:adbd77a90bde 3.0
Merged revisions 69025 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/branches/py3k
........
r69025 | mark.dickinson | 2009-01-27 18:17:45 +0000 (Tue, 27 Jan 2009) | 3 lines
Issue #1717: Remove cmp. Stage 1: remove all uses of cmp and __cmp__ from
the standard library and tests.
........
| author | Mark Dickinson <dickinsm@gmail.com> |
|---|---|
| date | Tue, 27 Jan 2009 18:31:30 +0000 |
| parents | a57d10d6bc89 |
| children | 9c1f06b273f7 |
line wrap: on
line diff
--- a/Lib/test/test_long.py Tue Jan 27 11:04:59 2009 +0000 +++ b/Lib/test/test_long.py Tue Jan 27 18:31:30 2009 +0000 @@ -696,7 +696,8 @@ 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): @@ -726,8 +727,8 @@ 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))
