Skip to content

Commit

Permalink
Add test for datetime subclass
Browse files Browse the repository at this point in the history
  • Loading branch information
nick-merrill committed May 17, 2023
1 parent 1865615 commit 306a959
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions tests/test_converters.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,15 @@ def test_default_values():
assert field.type == graphene.String
assert field.default_value == "hi"

class DatetimeSubclass(datetime.datetime):
pass

class TimeSubclass(datetime.time):
pass

class DateSubclass(datetime.date):
pass


@pytest.mark.parametrize(
"input, expected",
Expand All @@ -60,6 +69,10 @@ def test_default_values():
((datetime.date, datetime.date(2019, 1, 1)), graphene.Date),
((datetime.time, datetime.time(15, 29)), graphene.Time),
((datetime.datetime, datetime.datetime(2019, 1, 1, 1, 37)), graphene.DateTime),
# Tests support for datetime mocking libraries like Freezegun
((DatetimeSubclass, DatetimeSubclass(2019, 1, 1, 1, 37)), graphene.DateTime),
((DateSubclass, DateSubclass(2019, 1, 1)), graphene.Date),
((TimeSubclass, TimeSubclass(15, 29)), graphene.Time),
],
)
def test_builtin_scalars(input, expected):
Expand Down

0 comments on commit 306a959

Please sign in to comment.