summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_support.py
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>1993-01-26 13:04:43 (GMT)
committerGuido van Rossum <guido@python.org>1993-01-26 13:04:43 (GMT)
commit35fb82a33f4bc78be1f7d219b8ebd078b37c90cb (patch)
tree1075bc3db6c7e05e13fb9e247b447c1e085c3cfe /Lib/test/test_support.py
parent93f07400737a430ce642b4e7f6c9bd3e4460229c (diff)
downloadcpython-35fb82a33f4bc78be1f7d219b8ebd078b37c90cb.zip
cpython-35fb82a33f4bc78be1f7d219b8ebd078b37c90cb.tar.gz
cpython-35fb82a33f4bc78be1f7d219b8ebd078b37c90cb.tar.bz2
* os.py: _exit doesn't exist in all variations of posix
* Added fcmp() to test_support.py and use it in test*.py
Diffstat (limited to 'Lib/test/test_support.py')
-rw-r--r--Lib/test/test_support.py19
1 files changed, 19 insertions, 0 deletions
diff --git a/Lib/test/test_support.py b/Lib/test/test_support.py
index c6d0611..7a76664 100644
--- a/Lib/test/test_support.py
+++ b/Lib/test/test_support.py
@@ -18,5 +18,24 @@ def forget(modname):
except os.error:
pass
+FUZZ = 1e-6
+
+def fcmp(x, y): # fuzzy comparison function
+ if type(x) == type(0.0) or type(y) == type(0.0):
+ 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([])):
+ 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)
+
TESTFN = '@test' # Filename used for testing
from os import unlink