Hello,
It looks like the ranges of the
decimals() strategy shift/round when the places argument is used as well. For example (working but not a minimal example):
>>> min_ = decimal.Decimal(f"0.{'0'*63}1")
>>> max_ = decimal.Decimal(f"{'9'*64}.{'9'*64}")
>>> @hypothesis.given(st.decimals(min_value=min_, max_value=max_))
... def test(d):
... assert min_ <= d <= max_
works just fine. However, add e.g. a places=2 argument then the generated values exceed the min/max range and the assertion fires:
>>> test()
assert min_ <= d <= max_
^^^^^^^^^^^^^^^^^
AssertionError
Falsifying example: test(
d=int_to_decimal(
1_000_000_000_000_000_000_000_000_000_000_000_000_000_000_000_000_000_000_000_000_000_000,
),
)
For now, using a filter() strategy works, but perhaps this should be handled by the strategy itself? I have a suspicion that the decimal context & rounding (
docs) gets in the way here 🤔
Thanks!
Jens