diff options
author | Karl-Johan Alm <karljohan-alm@garage.co.jp> | 2021-12-19 14:46:45 +0900 |
---|---|---|
committer | Karl-Johan Alm <karljohan-alm@garage.co.jp> | 2022-08-02 10:11:12 +0900 |
commit | 701a64f548662e01821765b2934b6e4b321fda6d (patch) | |
tree | 473f2e3ca625f1119ce10042a617749b9d9c4698 /test/functional | |
parent | ce3b75690d10426e97d087ca600140a19bf180b7 (diff) |
test: add support for Decimal to assert_approx
Diffstat (limited to 'test/functional')
-rw-r--r-- | test/functional/test_framework/util.py | 4 |
1 files changed, 4 insertions, 0 deletions
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: |