[Python-3000-checkins] r51430 - python/branches/p3yk/Lib/test/test_support.py

neal.norwitz python-3000-checkins at python.org
Mon Aug 21 18:27:32 CEST 2006


Author: neal.norwitz
Date: Mon Aug 21 18:27:31 2006
New Revision: 51430

Modified:
   python/branches/p3yk/Lib/test/test_support.py
Log:
use isinstance instead of type.  Use bool instead of int for flag.

Modified: python/branches/p3yk/Lib/test/test_support.py
==============================================================================
--- python/branches/p3yk/Lib/test/test_support.py	(original)
+++ python/branches/p3yk/Lib/test/test_support.py	Mon Aug 21 18:27:31 2006
@@ -110,15 +110,14 @@
 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:
@@ -128,9 +127,9 @@
 
 try:
     unicode
-    have_unicode = 1
+    have_unicode = True
 except NameError:
-    have_unicode = 0
+    have_unicode = False
 
 is_jython = sys.platform.startswith('java')
 


More information about the Python-3000-checkins mailing list