Extend unittest's fail*AlmostEqual methods to work on complex numbers.
This commit is contained in:
parent
d3f6c9d17b
commit
1cc5544345
@ -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))
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user