Skip to content

Commit

Permalink
Fix patching not returning datetime subclasses
Browse files Browse the repository at this point in the history
  • Loading branch information
adamchainz committed May 1, 2024
1 parent 9ced2bb commit 210f9d1
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions tests/test_time_machine.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,15 @@ def test_datetime_now_arg():
)


def test_datetime_now_subclass():
class MyDatetime(dt.datetime):
pass

with time_machine.travel(EPOCH):
now = MyDatetime.now()
assert isinstance(now, MyDatetime)


def test_datetime_utcnow():
with time_machine.travel(EPOCH):
now = dt.datetime.utcnow()
Expand Down

0 comments on commit 210f9d1

Please sign in to comment.