Skip to content

Commit 5b3e33e

Browse files
committed
fix tests
1 parent 5dd6c7e commit 5b3e33e

File tree

3 files changed

+13
-22
lines changed

3 files changed

+13
-22
lines changed

hypothesis-python/tests/conjecture/test_test_data.py

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -90,21 +90,6 @@ def test_can_mark_invalid():
9090
assert x.status == Status.INVALID
9191

9292

93-
@given(st.data(), st.integers(1, 100))
94-
def test_can_draw_weighted_integer_range(data, n):
95-
weights = [1] * n + [0] * n
96-
for _ in range(10):
97-
# If the weights are working, then we'll never draw a value with weight=0
98-
x = data.conjecture_data.draw_integer(1, 2 * n, weights=weights)
99-
assert x <= n
100-
101-
102-
@given(st.binary(min_size=10))
103-
def test_can_draw_weighted_integer_range_2(buffer):
104-
data = ConjectureData.for_buffer(buffer)
105-
data.draw_integer(0, 7, weights=[1] * 8, shrink_towards=6)
106-
107-
10893
def test_can_mark_invalid_with_why():
10994
x = ConjectureData.for_buffer(b"")
11095
with pytest.raises(StopTest):

hypothesis-python/tests/conjecture/test_utils.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,9 @@ def test_single_bounds(lo, hi, to):
191191
def test_bounds_and_weights():
192192
for to in (0, 1, 2):
193193
data = ConjectureData.for_buffer([0] * 100 + [2] * 100)
194-
val = data.draw_integer(0, 2, shrink_towards=to, weights=[1, 1, 1])
194+
val = data.draw_integer(
195+
0, 2, shrink_towards=to, weights={0: 0.2, 1: 0.2, 2: 0.2}
196+
)
195197
assert val == to, to
196198

197199

hypothesis-python/tests/cover/test_filtered_strategy.py

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,20 +9,24 @@
99
# obtain one at https://mozilla.org/MPL/2.0/.
1010

1111
import hypothesis.strategies as st
12-
from hypothesis.control import BuildContext
1312
from hypothesis.internal.conjecture.data import ConjectureData
1413
from hypothesis.strategies._internal.strategies import FilteredStrategy
1514

15+
from tests.conjecture.common import run_to_buffer
16+
1617

1718
def test_filter_iterations_are_marked_as_discarded():
1819
variable_equal_to_zero = 0 # non-local references disables filter-rewriting
19-
x = st.integers(0, 255).filter(lambda x: x == variable_equal_to_zero)
20-
21-
data = ConjectureData.for_buffer([0, 2, 1, 0])
20+
x = st.integers().filter(lambda x: x == variable_equal_to_zero)
2221

23-
with BuildContext(data):
24-
assert data.draw(x) == 0
22+
@run_to_buffer
23+
def buf(data):
24+
data.draw_integer(forced=1)
25+
data.draw_integer(forced=0)
26+
data.mark_interesting()
2527

28+
data = ConjectureData.for_buffer(buf)
29+
assert data.draw(x) == 0
2630
assert data.has_discards
2731

2832

0 commit comments

Comments
 (0)