fix rounding errors in tests
This commit is contained in:
parent
33487521a7
commit
ab2ac1ec6a
1 changed files with 4 additions and 4 deletions
|
|
@ -3,7 +3,7 @@ from decimal import Decimal
|
|||
import pytest
|
||||
from money.currency import Currency
|
||||
|
||||
from xexe.money_amount import MoneyAmount
|
||||
from xexe.money_amount import DEFAULT_MAX_DECIMALS, MoneyAmount
|
||||
|
||||
|
||||
def test_money_amount_simple_creation_works():
|
||||
|
|
@ -23,13 +23,13 @@ def test_money_amount_takes_integer_amounts():
|
|||
def test_money_amount_takes_decimal_amounts():
|
||||
an_amount = MoneyAmount(amount=Decimal(10.5), currency=Currency.USD)
|
||||
|
||||
assert an_amount.amount == Decimal(10.5)
|
||||
assert an_amount.amount == Decimal(10.5).quantize(DEFAULT_MAX_DECIMALS)
|
||||
|
||||
|
||||
def test_money_amount_takes_proper_strings_amounts():
|
||||
an_amount = MoneyAmount(amount="10.55", currency=Currency.USD)
|
||||
|
||||
assert an_amount.amount == Decimal(10.55)
|
||||
assert an_amount.amount == Decimal(10.55).quantize(DEFAULT_MAX_DECIMALS)
|
||||
|
||||
|
||||
def test_money_amount_fails_with_ugly_strings():
|
||||
|
|
@ -46,4 +46,4 @@ def test_money_amount_takes_string_for_currency():
|
|||
def test_money_amount_works_with_8_decimal_positions():
|
||||
an_amount = MoneyAmount(amount="1.12345678", currency="USD")
|
||||
|
||||
assert an_amount == Decimal(1.12345678)
|
||||
assert an_amount.amount == Decimal(1.12345678).quantize(DEFAULT_MAX_DECIMALS)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue