Skip to content

Commit c9c9464

Browse files
committed
improve one_of shrinking coverage case
1 parent 282edb1 commit c9c9464

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

hypothesis-python/tests/conjecture/test_shrinker.py

+9-8
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
from hypothesis.internal.conjecture.utils import Sampler
2727
from hypothesis.internal.floats import MAX_PRECISE_INTEGER
2828

29-
from tests.common.debug import minimal
3029
from tests.conjecture.common import (
3130
SOME_LABEL,
3231
float_kw,
@@ -661,10 +660,12 @@ def shrinker(data: ConjectureData):
661660
def test_shrinking_one_of_with_same_shape():
662661
# This is a covering test for our one_of shrinking logic for the case when
663662
# the choice sequence *doesn't* change shape in the newly chosen one_of branch.
664-
#
665-
# There are relatively few tests in our suite that cover this (and previously
666-
# none in the covering subset). I chose the simplest one to copy here, but
667-
# haven't yet put time into extracting the essence of a test case that
668-
# covers this case, which is why we're using st.permutations here instead of
669-
# something more fundamental / obviously testing what we want.
670-
minimal(st.permutations(list(range(5))), lambda x: x[0] != 0)
663+
@shrinking_from([1, 0])
664+
def shrinker(data: ConjectureData):
665+
n = data.draw_integer(0, 1)
666+
data.draw_integer()
667+
if n == 1:
668+
data.mark_interesting()
669+
670+
shrinker.initial_coarse_reduction()
671+
assert shrinker.choices == (1, 0)

0 commit comments

Comments
 (0)