Closed bmabey closed 4 years ago
does this help?
from typing import Union
from uuid import UUID
from hypothesis import strategies
from sqlalchemy.dialects import postgresql
from hypothesis_sqlalchemy.columnar.values import from_type
from hypothesis_sqlalchemy.hints import Strategy
# somewhere during project/tests start, e.g. in `conftest.py` for `pytest`
@from_type.register(postgresql.UUID)
def uuid_type_values_factory(type_: postgresql.UUID
) -> Strategy[Union[str, UUID]]:
result = strategies.uuids()
if not type_.as_uuid:
result = result.map(str)
return result
since this type is Postgres-specific I'm thinking about the way for specifying a dialect for generating tables with this kind of column
UUID
is not a supported inferred strategy but I believe it should be.. maybe it as simple as adding a mapping ofUUID
to the UUID strategy in this dictionary: https://github.com/lycantropos/hypothesis_sqlalchemy/blob/master/hypothesis_sqlalchemy/columnar/values.py#L51-L63Here is how you reproduce the issue:
The end of the stack trace looks like: