Skip to content

Commit 701a64f

Browse files
committed
test: add support for Decimal to assert_approx
1 parent ce3b756 commit 701a64f

File tree

1 file changed

+4
-0
lines changed
  • test/functional/test_framework

1 file changed

+4
-0
lines changed

test/functional/test_framework/util.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,10 @@
2929

3030
def assert_approx(v, vexp, vspan=0.00001):
3131
"""Assert that `v` is within `vspan` of `vexp`"""
32+
if isinstance(v, Decimal) or isinstance(vexp, Decimal):
33+
v=Decimal(v)
34+
vexp=Decimal(vexp)
35+
vspan=Decimal(vspan)
3236
if v < vexp - vspan:
3337
raise AssertionError("%s < [%s..%s]" % (str(v), str(vexp - vspan), str(vexp + vspan)))
3438
if v > vexp + vspan:

0 commit comments

Comments
 (0)