It should be possible to call strategies.emails(max_size=N) as database column for emails may have constraint much smaller than 255.
Currently I have worked it around with:
@defines_strategy_with_reusable_values
def emails(max_size: int = None,) -> SearchStrategy[str]:
"""A strategy for generating email addresses as unicode strings. The
address format is specified in :rfc:`5322#section-3.4.1`. Values shrink
towards shorter local-parts and host domains.
This strategy is useful for generating "user data" for tests, as
mishandling of email addresses is a common source of bugs.
"""
from hypothesis.provisional import domains
local_chars = string.ascii_letters + string.digits + "!#$%&'*+-/=^_`{|}~"
local_part = text(local_chars, min_size=1, max_size=64)
# TODO: include dot-atoms, quoted strings, escaped chars, etc in local part
return builds("{}@{}".format, local_part, domains()).filter(
lambda addr: len(addr) <= (max_size if max_size is not None else 254)
)
Are you talking about hypothesis.strategies.emails? If yes -- it should be an improvement request to hypothesis repository since it is not a part of hypothesis_sqlalchemy API.
It should be possible to call
strategies.emails(max_size=N)
as database column for emails may have constraint much smaller than 255.Currently I have worked it around with: