Skip to content

Commit

Permalink
fix: Simplify precision loss test (#67)
Browse files Browse the repository at this point in the history
  • Loading branch information
antonagestam authored Oct 8, 2023
1 parent 9851c44 commit 88c7822
Showing 1 changed file with 3 additions and 18 deletions.
21 changes: 3 additions & 18 deletions tests/test_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,24 +107,9 @@ def test_zero_returns_cached_instance_of_money_zero(self) -> None:
assert SEK.zero.subunits == 0
assert SEK.zero.currency is SEK

@given(
currency=currencies(),
value=decimals(
min_value=very_small_decimal,
allow_nan=False,
allow_infinity=False,
),
)
@example(currency=SEK, value=Decimal("0.01"))
def test_normalize_value_raises_for_precision_loss(
self,
currency: Currency,
value: Decimal,
) -> None:
with pytest.raises((ParseError, InvalidOperation)):
currency.normalize_to_subunits(value)
currency.normalize_to_subunits(value + very_small_decimal)
currency.normalize_to_subunits(value - very_small_decimal)
def test_normalize_value_raises_for_precision_loss(self) -> None:
with pytest.raises(ParseError):
SEK.normalize_to_subunits(Decimal("0.01") + very_small_decimal)

@given(
value=integers(max_value=-1) | decimals(max_value=Decimal("-0.000001")),
Expand Down

0 comments on commit 88c7822

Please sign in to comment.