I have a function like so (it's actually a class, but that's not relevant given Python's duck typing):
def myfunc(a=None, b=None):
<snip>
Now I want to write a Hypothesis test which always supplies a
, but only sometimes b
.
I tried
from hypothesis import given, strategies as strat
@given(a=strat.booleans())
@given(b=strat.integers(min_value=1) | strat.nothing())
def test_model_properties(self, **kwargs):
myval = myfunc(**kwargs)
<snip>
But it seems that when it gets strat.nothing()
just skips that test run (I get hypothesis.errors.FailedHealthCheck: It looks like your strategy is filtering out a lot of data.
when using that as the sole strategy for b
).
How can I only sometimes supply an argument with a Hypothesis test? Do I need to write two tests, one with b
and one without?