-
Notifications
You must be signed in to change notification settings - Fork 269
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
make sure fromtimestamp always return FakeDateTime #475
Conversation
The proposed code change seems to be no change of behavior. Could you point out what it changes? |
In the
However, the fake one depend on the freeze time zone:
So if we make these steps:
we will have a type chain like this:
Since we know there are different behavior between That's why I added the test. |
freezegun/api.py
Outdated
tz = dateutil.tz.tzoffset("freezegun", cls._tz_offset()) | ||
result = real_datetime.fromtimestamp(t, tz=tz).replace(tzinfo=None) | ||
else: | ||
result = datetime_to_fakedatetime(real_datetime.fromtimestamp(t, tz)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
result = datetime_to_fakedatetime(real_datetime.fromtimestamp(t, tz)) | |
result = real_datetime.fromtimestamp(t, tz) |
The datetime_to_fakedatetime
already happens at the end - no need to duplicate this call.
Happy to merge once that's fixed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed. thanks for pointing this out.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great - thanks for the fix @Koswu!
This fix #344
This is my first PR, if something goes wrong, please let me know, PTAL