summaryrefslogtreecommitdiff
path: root/testlib.py
diff options
context:
space:
mode:
authorNicolas Chauvat <nicolas.chauvat@logilab.fr>2010-12-27 14:44:56 +0100
committerNicolas Chauvat <nicolas.chauvat@logilab.fr>2010-12-27 14:44:56 +0100
commit8a7bcd84b4fa5eb34a32088e89444443d96e6cc3 (patch)
treec7a70c29b4c455de23b79d627ef83245e2b43fc8 /testlib.py
parente770ad09f3ae646b823d6275192f4c8290885d42 (diff)
downloadlogilab-common-8a7bcd84b4fa5eb34a32088e89444443d96e6cc3.tar.gz
[testlib] forgot qrefresh before qfinish :(
Diffstat (limited to 'testlib.py')
-rw-r--r--testlib.py8
1 files changed, 5 insertions, 3 deletions
diff --git a/testlib.py b/testlib.py
index 1a7bad6..b390175 100644
--- a/testlib.py
+++ b/testlib.py
@@ -1040,19 +1040,21 @@ succeeded test into", osp.join(os.getcwd(), FILE_RESTART)
@deprecated('Non-standard. Please use assertAlmostEqual instead.')
def assertFloatAlmostEquals(self, obj, other, prec=1e-5,
- relative_prec=1e-5, msg=None):
+ relative=False, msg=None):
"""compares if two floats have a distance smaller than expected
precision.
:param obj: a Float
:param other: another Float to be comparted to <obj>
:param prec: a Float describing the precision
- :param relative_prec: a Float describing the relative precision
+ :param relative: boolean switching to relative/absolute precision
:param msg: a String for a custom message
"""
if msg is None:
msg = "%r != %r" % (obj, other)
- self.assert_(math.fabs(obj - other) < prec+relative_prec*math.fabs(obj), msg)
+ if relative:
+ prec = prec*math.fabs(obj)
+ self.assert_(math.fabs(obj - other) < prec, msg)
#@deprecated('[API] Non-standard. Please consider using a context here')
def failUnlessRaises(self, excClass, callableObj, *args, **kwargs):