Skip to content

Commit 43a65dc

Browse files
committed
Revert changes to integers/floats label calculation
1 parent f1e78f7 commit 43a65dc

File tree

3 files changed

+15
-20
lines changed

3 files changed

+15
-20
lines changed

hypothesis-python/src/hypothesis/strategies/_internal/core.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1886,7 +1886,10 @@ def do_draw(self, data):
18861886
return self.definition(data.draw, *self.args, **self.kwargs)
18871887

18881888
def calc_label(self) -> int:
1889-
return calc_label_from_callable(self.definition)
1889+
return combine_labels(
1890+
self.class_label,
1891+
calc_label_from_callable(self.definition),
1892+
)
18901893

18911894

18921895
class DrawFn(Protocol):

hypothesis-python/src/hypothesis/strategies/_internal/numbers.py

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
from hypothesis.control import reject
1717
from hypothesis.errors import InvalidArgument
1818
from hypothesis.internal.conjecture.data import ConjectureData
19-
from hypothesis.internal.conjecture.utils import calc_label_from_hash, combine_labels
2019
from hypothesis.internal.filtering import (
2120
get_float_predicate_bounds,
2221
get_integer_predicate_bounds,
@@ -67,13 +66,6 @@ def __repr__(self) -> str:
6766
return f"integers(max_value={self.end})"
6867
return f"integers({self.start}, {self.end})"
6968

70-
def calc_label(self) -> int:
71-
return combine_labels(
72-
self.class_label,
73-
calc_label_from_hash(self.start),
74-
calc_label_from_hash(self.end),
75-
)
76-
7769
def do_draw(self, data: ConjectureData) -> int:
7870
# For bounded integers, make the bounds and near-bounds more likely.
7971
weights = None
@@ -189,15 +181,6 @@ def __repr__(self) -> str:
189181
f"{self.allow_nan=}, {self.smallest_nonzero_magnitude=})"
190182
).replace("self.", "")
191183

192-
def calc_label(self) -> int:
193-
return combine_labels(
194-
self.class_label,
195-
calc_label_from_hash(self.min_value),
196-
calc_label_from_hash(self.max_value),
197-
calc_label_from_hash(self.allow_nan),
198-
calc_label_from_hash(self.smallest_nonzero_magnitude),
199-
)
200-
201184
def do_draw(self, data: ConjectureData) -> float:
202185
return data.draw_float(
203186
min_value=self.min_value,

hypothesis-python/tests/cover/test_direct_strategies.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -589,14 +589,23 @@ def test_builds_error_messages(data):
589589
@pytest.mark.parametrize(
590590
"strat_a,strat_b",
591591
[
592-
(st.integers(), st.integers(0)),
592+
pytest.param(
593+
st.integers(),
594+
st.integers(0),
595+
marks=pytest.mark.xfail(
596+
# this is the exception raised by failed pytest.warns(),
597+
# ref https://github.com/pytest-dev/pytest/issues/8928
598+
raises=pytest.fail.Exception,
599+
strict=True,
600+
reason="constraints not checked",
601+
),
602+
),
593603
(st.builds(int), st.builds(float)),
594604
(st.none(), st.integers()),
595605
(
596606
st.composite(lambda draw: draw(st.none()))(),
597607
st.composite(lambda draw: draw(st.integers()))(),
598608
),
599-
(st.builds(int, st.integers()), st.builds(int, st.integers(0))),
600609
],
601610
)
602611
def test_incompatible_shared_strategies_warns(strat_a, strat_b):

0 commit comments

Comments
 (0)