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
fromdatetimeimportdate, datetime, time, timezoneimporttime_machinewithtime_machine.travel(datetime(2023, 2, 16, 7, 44, 0, tzinfo=timezone.utc)):
now=datetime.combine(date.today(), time.min) # For example 2023-02-16 00:00:00, but no timezone yetnow=now.astimezone() # Local timezonenow_utc=now.astimezone(timezone.utc)
assertnow_utc.timestamp() ==1676505600, f'TS is said to be {now_utc.timestamp()}'
In this example on my computer (GMT+1) this fails.
I think the reason is because astimezone will bypass the time-machine and go to the system time to get the current timezone information. Instead of taking that from the mock?
The text was updated successfully, but these errors were encountered:
Python Version
3.9.13
pytest Version
7.1.2
Package Version
2.9.0
Description
In this example on my computer (GMT+1) this fails.
I think the reason is because
astimezone
will bypass the time-machine and go to the system time to get the current timezone information. Instead of taking that from the mock?The text was updated successfully, but these errors were encountered: