I am having issues with Hypothesis generating strings which do not respect the given min/max sizes. Example:
@given(
st.text(
alphabet=st.from_regex(regex=r"^[a-z][b-z]$", fullmatch=True),
min_size=0,
max_size=15,
)
)
def test_foobar(username: str):
assert len(username) <= 20
Output:
> assert len(username) <= 20
E AssertionError: assert 22 <= 20
E + where 22 = len('ababababababababababab')
E Falsifying example: test_foobar(
E username='ababababababababababab',
E )
I've tried using \A
and \Z
instead of ^
and $
too, but nothing seems to help.
I'm running it with:
$ pytest --hypothesis-seed=2
I have Pytest 7.2.0 and Hypothesis 6.56.4, on Python 3.9.
What am I missing?