mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-03-06 14:19:59 -05:00
test: add support for Decimal to assert_approx
This commit is contained in:
parent
ce3b75690d
commit
701a64f548
1 changed files with 4 additions and 0 deletions
|
@ -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:
|
||||
|
|
Loading…
Add table
Reference in a new issue