summaryrefslogtreecommitdiff
path: root/pint/testsuite/__init__.py
diff options
context:
space:
mode:
authorHernan Grecco <hernan.grecco@gmail.com>2013-11-06 12:25:01 -0300
committerHernan Grecco <hernan.grecco@gmail.com>2013-11-06 12:25:01 -0300
commit70ccea19c82d6b5933189eee738f893183d1fa96 (patch)
tree2a40ef9711e1b1ed7786ff2355ca5b6e95ce4443 /pint/testsuite/__init__.py
parentf34c235d33b0e6856da1b30625850947c3ce53d5 (diff)
downloadpint-70ccea19c82d6b5933189eee738f893183d1fa96.tar.gz
Context parsing from definition file
Diffstat (limited to 'pint/testsuite/__init__.py')
-rw-r--r--pint/testsuite/__init__.py15
1 files changed, 15 insertions, 0 deletions
diff --git a/pint/testsuite/__init__.py b/pint/testsuite/__init__.py
index 9a522ce..cf9344e 100644
--- a/pint/testsuite/__init__.py
+++ b/pint/testsuite/__init__.py
@@ -69,6 +69,21 @@ class TestCase(unittest.TestCase):
else:
unittest.TestCase.assertAlmostEqual(self, first, second, places, msg, delta)
+ def assertAlmostEqualRelError(self, first, second, rel, msg=None):
+ if isinstance(first, self.Q_) and isinstance(second, self.Q_):
+ second = second.to(first)
+ val = abs((second - first) / (second + first))
+ elif isinstance(first, self.Q_):
+ self.assertTrue(first.dimensionless)
+ first = first.to('')
+ val = abs((second - first) / (second + first))
+ elif isinstance(second, self.Q_):
+ self.assertTrue(second.dimensionless)
+ second = second.to('')
+ val = abs((second - first) / (second + first))
+ else:
+ val = abs((second - first) / (second + first))
+ self.assertLess(val, rel, msg=msg)
def testsuite():
"""A testsuite that has all the pyflim tests.