The old test parsed to a datetime without a tz, which was interpreted as
the local time zone when rendering back to a string. Specify that it's a
UTC datetime so that behavior is consistent regardless of the test host
timezone.
Signed-off-by: Sage Weil <sage@newdream.net>
(cherry picked from commit
78aca4db249c409d0cd5a24bfae81e55cf930bc3)
def test_datetime_to_str_2():
- dt = datetime.datetime.strptime('2019-04-24T17:06:53.039991',
- '%Y-%m-%dT%H:%M:%S.%f')
+ # note: tz isn't specified in the string, so explicitly store this as UTC
+ dt = datetime.datetime.strptime(
+ '2019-04-24T17:06:53.039991',
+ '%Y-%m-%dT%H:%M:%S.%f'
+ ).replace(tzinfo=datetime.timezone.utc)
assert datetime_to_str(dt) == '2019-04-24T17:06:53.039991Z'