From 1cc5544345a6cfbe034f2c804c54660763320220 Mon Sep 17 00:00:00 2001 From: Jeffrey Yasskin Date: Thu, 6 Sep 2007 18:55:17 +0000 Subject: Extend unittest's fail*AlmostEqual methods to work on complex numbers. --- Lib/unittest.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Lib/unittest.py b/Lib/unittest.py index 7dac499..a023c67 100644 --- a/Lib/unittest.py +++ b/Lib/unittest.py @@ -339,7 +339,7 @@ class TestCase: 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 @@ class TestCase: 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)) -- cgit v0.12