[Python-3000-checkins] r58017 - python/branches/py3k/Lib/unittest.py

jeffrey.yasskin python-3000-checkins at python.org
Thu Sep 6 20:55:17 CEST 2007


Author: jeffrey.yasskin
Date: Thu Sep  6 20:55:17 2007
New Revision: 58017

Modified:
   python/branches/py3k/Lib/unittest.py
Log:
Extend unittest's fail*AlmostEqual methods to work on complex numbers.


Modified: python/branches/py3k/Lib/unittest.py
==============================================================================
--- python/branches/py3k/Lib/unittest.py	(original)
+++ python/branches/py3k/Lib/unittest.py	Thu Sep  6 20:55:17 2007
@@ -339,7 +339,7 @@
            Note that decimal places (from zero) are usually not the same
            as significant digits (measured from the most signficant digit).
         """
-        if round(second-first, places) != 0:
+        if round(abs(second-first), places) != 0:
             raise self.failureException(msg or '%r != %r within %r places'
                                                % (first, second, places))
 
@@ -351,7 +351,7 @@
            Note that decimal places (from zero) are usually not the same
            as significant digits (measured from the most signficant digit).
         """
-        if round(second-first, places) == 0:
+        if round(abs(second-first), places) == 0:
             raise self.failureException(msg or '%r == %r within %r places'
                                                % (first, second, places))
 


More information about the Python-3000-checkins mailing list