Skip to content

st.decimals can return out of bounds values with places #4651

@Liam-DeVoe

Description

@Liam-DeVoe

As reported by on the mailing list: https://groups.google.com/g/hypothesis-users/c/GVw-eZlmto0/m/QCClp1kfAwAJ?utm_medium=email&utm_source=footer

min_ = decimal.Decimal(f"0.{'0'*63}1")
max_ = decimal.Decimal(f"{'9'*64}.{'9'*64}")
@given(decimals(min_value=min_, max_value=max_, places=2))
@settings(max_examples=10000)
def f(d):
    assert min_ <= d <= max_

Fails with:

Falsifying example: f(
    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,
    ),
)

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugsomething is clearly wrong here

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions