Skip to content

Commit ea4142b

Browse files
arielb1Ariel Ben-Yehuda
authored andcommitted
avoid FailedHealthCheck in test_double (#4879)
Co-authored-by: Ariel Ben-Yehuda <arielby@amazon.com>
1 parent e1630fb commit ea4142b

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

newsfragments/4879.fixed.md

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
* fixed spurious `test_double` failures.

pytests/tests/test_othermod.py

+7-2
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,16 @@
33

44
from pyo3_pytests import othermod
55

6-
INTEGER32_ST = st.integers(min_value=(-(2**31)), max_value=(2**31 - 1))
6+
INTEGER31_ST = st.integers(min_value=(-(2**30)), max_value=(2**30 - 1))
77
USIZE_ST = st.integers(min_value=othermod.USIZE_MIN, max_value=othermod.USIZE_MAX)
88

99

10-
@given(x=INTEGER32_ST)
10+
# If the full 32 bits are used here, then you can get failures that look like this:
11+
# hypothesis.errors.FailedHealthCheck: It looks like your strategy is filtering out a lot of data.
12+
# Health check found 50 filtered examples but only 7 good ones.
13+
#
14+
# Limit the range to 31 bits to avoid this problem.
15+
@given(x=INTEGER31_ST)
1116
def test_double(x):
1217
expected = x * 2
1318
assume(-(2**31) <= expected <= (2**31 - 1))

0 commit comments

Comments
 (0)