Skip to content

Commit

Permalink
use minimal for test_can_shrink_variable_draws
Browse files Browse the repository at this point in the history
  • Loading branch information
tybug committed May 9, 2024
1 parent 1590c2f commit 796ff00
Showing 1 changed file with 8 additions and 11 deletions.
19 changes: 8 additions & 11 deletions hypothesis-python/tests/conjecture/test_engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,14 @@
from hypothesis.internal.conjecture.shrinker import Shrinker, block_program
from hypothesis.internal.entropy import deterministic_PRNG

from tests.common.debug import minimal
from tests.common.strategies import SLOW, HardToShrink
from tests.common.utils import no_shrink
from tests.conjecture.common import (
SOME_LABEL,
TEST_SETTINGS,
buffer_size_limit,
run_to_buffer,
run_to_data,
shrinking_from,
)

Expand Down Expand Up @@ -440,17 +440,14 @@ def _(data):
def test_can_shrink_variable_draws(n_large):
target = 128 * n_large

@run_to_data
def data(data):
n = data.draw_integer(0, 15)
b = [data.draw_integer(0, 255) for _ in range(n)]
if sum(b) >= target:
data.mark_interesting()

x = data.buffer
@st.composite
def strategy(draw):
n = draw(st.integers(0, 15))
return [draw(st.integers(0, 255)) for _ in range(n)]

assert x.count(0) == 0
assert sum(x[1:]) == target
ints = minimal(strategy(), lambda ints: sum(ints) >= target)
# should look like [4, 255, 255, 255]
assert ints == [target % 255] + [255] * (len(ints) - 1)


def test_run_nothing():
Expand Down

0 comments on commit 796ff00

Please sign in to comment.