Skip to content

Commit

Permalink
Deflake test?
Browse files Browse the repository at this point in the history
  • Loading branch information
Zac-HD committed Feb 15, 2024
1 parent 0a45a47 commit c599b79
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
4 changes: 3 additions & 1 deletion hypothesis-python/src/hypothesis/internal/conjecture/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -1589,7 +1589,9 @@ def draw_float(

if forced is not None:
assert allow_nan or not math.isnan(forced)
assert math.isnan(forced) or min_value <= forced <= max_value
assert math.isnan(forced) or (
sign_aware_lte(min_value, forced) and sign_aware_lte(forced, max_value)
)

kwargs: FloatKWargs = {
"min_value": min_value,
Expand Down
6 changes: 5 additions & 1 deletion hypothesis-python/tests/conjecture/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
from hypothesis.internal.conjecture.engine import BUFFER_SIZE, ConjectureRunner
from hypothesis.internal.conjecture.utils import calc_label_from_name
from hypothesis.internal.entropy import deterministic_PRNG
from hypothesis.internal.floats import sign_aware_lte
from hypothesis.strategies._internal.strings import OneCharStringStrategy, TextStrategy

from tests.common.strategies import intervals
Expand Down Expand Up @@ -201,7 +202,10 @@ def draw_float_kwargs(
min_value = draw(st.floats(max_value=pivot, allow_nan=False))

if use_max_value:
min_val = min_value if not pivot is not None else max(min_value, pivot)
if pivot is None:
min_val = min_value
else:
min_val = pivot if sign_aware_lte(min_value, pivot) else min_value
max_value = draw(st.floats(min_value=min_val, allow_nan=False))

return {"min_value": min_value, "max_value": max_value, "forced": forced}
Expand Down

0 comments on commit c599b79

Please sign in to comment.