Using the @given decorator Hypothesis will generate values in the given range. By defaul it will the function up to a 100 times.
This can be changed by adding @settings(max_examples=200).
from hypothesis import given, settings, strategies as st
count = 0
@given(x=st.integers(1, 1000), y=st.integers(1, 3))
@settings(max_examples=200)
def test_hypothesis(x, y):
#print(f"x:{x}")
global count
count += 1
def teardown_module():
print(f"count: {count}")
To run the example first install the required modules:
pip install hypothesis pytest
Then run pytest with the -s flag:
pytest -s examples/check_hypothesis.py
See the documentation of the settings
See the presentation about Hypothesis