Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

subclasses of datetime return datetime rather than Self while time is mocked #446

Open
tamird opened this issue Apr 30, 2024 · 0 comments · May be fixed by #447
Open

subclasses of datetime return datetime rather than Self while time is mocked #446

tamird opened this issue Apr 30, 2024 · 0 comments · May be fixed by #447

Comments

@tamird
Copy link

tamird commented Apr 30, 2024

Python Version

3.12.2

pytest Version

8.1.1

Package Version

2.14.1

Description

This code runs fine:

class MyDT(datetime):
    pass

my_dt = MyDT.now()
assert type(my_dt) == MyDT

This code asserts:

class MyDT(datetime):
    pass

with time_machine.travel(0):
    my_dt = MyDT.now()
assert type(my_dt) == MyDT
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant