From 701a64f548662e01821765b2934b6e4b321fda6d Mon Sep 17 00:00:00 2001 From: Karl-Johan Alm Date: Sun, 19 Dec 2021 14:46:45 +0900 Subject: [PATCH] test: add support for Decimal to assert_approx --- test/functional/test_framework/util.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/test/functional/test_framework/util.py b/test/functional/test_framework/util.py index fe61ff95f8..bfc835f272 100644 --- a/test/functional/test_framework/util.py +++ b/test/functional/test_framework/util.py @@ -29,6 +29,10 @@ logger = logging.getLogger("TestFramework.utils") def assert_approx(v, vexp, vspan=0.00001): """Assert that `v` is within `vspan` of `vexp`""" + if isinstance(v, Decimal) or isinstance(vexp, Decimal): + v=Decimal(v) + vexp=Decimal(vexp) + vspan=Decimal(vspan) if v < vexp - vspan: raise AssertionError("%s < [%s..%s]" % (str(v), str(vexp - vspan), str(vexp + vspan))) if v > vexp + vspan: