This seems to be connected to the amount of successful tests hypothesis
tries to generate:
>>> from hypothesis import given, strategies as st
>>> @given(st.integers(0,1), st.integers(0,2))
... def test(x, y):
... print(x, y)
... assert True
...
>>> test()
0 0
1 1
1 0
1 2
1 1
0 1
0 0
1 2
0 2
0 2
1 0
1 2
0 1
0 1
1 2
[snip…]
See, this part of the docs, for instance, the default amount of successful test cases should be 100. So trying to generate more and more data to only restrict to 6 cases is rapidly failing to find one of these 6 cases.
The simplest approach can be to just limit the amount of examples needed for this test to pass:
>>> from hypothesis import settings
>>> @settings(max_examples=30)
... @given(st.integers(0,1), st.integers(0,2))
... def test(x, y):
... print(x, y)
... assert True
...
>>> test()
0 0
1 1
1 0
0 2
1 2
0 1
0 1
1 1
1 0
1 1
0 1
1 2
1 1
0 0
0 2
0 2
0 0
1 2
1 0
0 1
1 0
1 0
0 1
1 2
1 1
0 2
0 0
1 2
0 0
0 2
An other approach, given the few amount of test cases, would be to explicit them all using @example
and ask hypothesis
to only run those explicit examples:
>>> from hypothesis import given, example, settings, Phase, strategies as st
>>> @settings(phases=(Phase.explicit,))
... @given(x=st.integers(), y=st.integers())
... @example(x=0, y=0)
... @example(x=0, y=1)
... @example(x=0, y=2)
... @example(x=1, y=0)
... @example(x=1, y=1)
... @example(x=1, y=2)
... def test(x, y):
... print(x, y)
... assert True
...
>>> test()
0 0
0 1
0 2
1 0
1 1
1 2
Also note that st.just(0) | st.just(1)
is equivalent to st.one_of(st.just(0), st.just(1))
so choose an approach and stick to it, but don't mix them.