summaryrefslogtreecommitdiffstats
path: root/Lib/unittest.py
diff options
context:
space:
mode:
authorJeffrey Yasskin <jyasskin@gmail.com>2007-09-06 18:55:17 (GMT)
committerJeffrey Yasskin <jyasskin@gmail.com>2007-09-06 18:55:17 (GMT)
commit1cc5544345a6cfbe034f2c804c54660763320220 (patch)
treefff1cd3f679a40aea512310fe00fa12507d34849 /Lib/unittest.py
parentd3f6c9d17b7ccbb1e2a887d871d35c30c36eca1e (diff)
downloadcpython-1cc5544345a6cfbe034f2c804c54660763320220.zip
cpython-1cc5544345a6cfbe034f2c804c54660763320220.tar.gz
cpython-1cc5544345a6cfbe034f2c804c54660763320220.tar.bz2
Extend unittest's fail*AlmostEqual methods to work on complex numbers.
Diffstat (limited to 'Lib/unittest.py')
-rw-r--r--Lib/unittest.py4
1 files 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))