You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
class TestSchema(BaseModel):
date_field: datetime.date
breaks in tests that use freezegun to freeze time:
E graphene_pydantic.converters.ConversionError: Don't know how to convert the Pydantic field ModelField(name='date_field', type=date, required=True) (<class 'datetime.date'>)
I believe the issue is because freezegun overwrites the type of datetime.date and datetime.datetime, so these lines in the graphene_pydantic converter (find_graphene_type()) don't evaluate to true:
I'm not sure if this is a weird fix or not, but changing the if condition to:
elif type_.__name__ == "date"
or
elif issubclass(type_, datetime.date):
fixes this use case.
A better suggestion (though I don't know the best way to implement) is to allow a custom type mappings so we don't have to rely on this switch statement.
The text was updated successfully, but these errors were encountered:
this schema
breaks in tests that use freezegun to freeze time:
I believe the issue is because freezegun overwrites the type of
datetime.date
anddatetime.datetime
, so these lines in thegraphene_pydantic
converter (find_graphene_type()
) don't evaluate to true:pydantic code: https://github.com/graphql-python/graphene-pydantic/blob/master/graphene_pydantic/converters.py#L186
freezegun code: https://github.com/spulec/freezegun/blob/master/freezegun/api.py#L637
related freezegun issue: spulec/freezegun#170
I'm not sure if this is a weird fix or not, but changing the if condition to:
or
fixes this use case.
A better suggestion (though I don't know the best way to implement) is to allow a custom type mappings so we don't have to rely on this switch statement.
The text was updated successfully, but these errors were encountered: