summaryrefslogtreecommitdiffstats
path: root/Lib/test
diff options
context:
space:
mode:
authorBrett Cannon <bcannon@gmail.com>2008-07-31 03:00:53 (GMT)
committerBrett Cannon <bcannon@gmail.com>2008-07-31 03:00:53 (GMT)
commitcda5ce24ed20a7e9f68282ac55b0d6949fe0c7db (patch)
treed0cc8c574112cdad5c0baf931b3d04e182f7da7d /Lib/test
parentf080e6d7e027c9576814dd57af3122ab2aff7aa9 (diff)
downloadcpython-cda5ce24ed20a7e9f68282ac55b0d6949fe0c7db.zip
cpython-cda5ce24ed20a7e9f68282ac55b0d6949fe0c7db.tar.gz
cpython-cda5ce24ed20a7e9f68282ac55b0d6949fe0c7db.tar.bz2
Backport test.support.fcmp() from 3.0 to silence -3 warnings.
Diffstat (limited to 'Lib/test')
-rw-r--r--Lib/test/test_support.py9
1 files changed, 4 insertions, 5 deletions
diff --git a/Lib/test/test_support.py b/Lib/test/test_support.py
index 145c154..1aa21d3 100644
--- a/Lib/test/test_support.py
+++ b/Lib/test/test_support.py
@@ -224,21 +224,20 @@ def bind_port(sock, host=HOST):
FUZZ = 1e-6
def fcmp(x, y): # fuzzy comparison function
- if type(x) == type(0.0) or type(y) == type(0.0):
+ if isinstance(x, float) or isinstance(y, float):
try:
- x, y = coerce(x, y)
fuzz = (abs(x) + abs(y)) * FUZZ
if abs(x-y) <= fuzz:
return 0
except:
pass
- elif type(x) == type(y) and type(x) in (type(()), type([])):
+ elif type(x) == type(y) and isinstance(x, (tuple, list)):
for i in range(min(len(x), len(y))):
outcome = fcmp(x[i], y[i])
if outcome != 0:
return outcome
- return cmp(len(x), len(y))
- return cmp(x, y)
+ return (len(x) > len(y)) - (len(x) < len(y))
+ return (x > y) - (x < y)
try:
unicode