11# pylint: disable=missing-docstring
22# pylint: disable=protected-access
33# pylint: disable=too-many-arguments
4- from datetime import datetime
4+ from datetime import datetime , UTC
55from zoneinfo import ZoneInfo
66
77import pytest
@@ -60,21 +60,21 @@ def test_from_format_returns(self, source, format_str, expected):
6060 for attribute , value in expected .items ():
6161 assert getattr (timestamp , attribute ) == value
6262
63- @pytest .mark .parametrize ("timezone" , [None , ZoneInfo ( " UTC" ) , ZoneInfo ("Europe/Berlin" )])
63+ @pytest .mark .parametrize ("timezone" , [None , UTC , ZoneInfo ("Europe/Berlin" )])
6464 def test_has_utc_if_timezone_was_set (self , timezone ):
6565 datetime_time = datetime .now (timezone )
6666 time_parser_time = TimeParser .now (timezone )
6767 assert time_parser_time .second == pytest .approx (datetime_time .second , abs = 1 )
6868 if timezone is None :
69- assert time_parser_time .tzinfo == ZoneInfo ( " UTC" )
69+ assert time_parser_time .tzinfo == UTC
7070 else :
7171 assert time_parser_time .tzinfo == timezone
7272
7373 def test_set_utc_if_timezone_is_missing_sets_timezone (self ):
7474 datetime_time = datetime .now ()
7575 assert datetime_time .tzinfo is None
7676 time_parser_time = TimeParser ._set_utc_if_timezone_is_missing (datetime_time )
77- assert time_parser_time .tzinfo is ZoneInfo ( " UTC" )
77+ assert time_parser_time .tzinfo is UTC
7878 assert time_parser_time .second == pytest .approx (datetime_time .second , abs = 1 )
7979
8080 @pytest .mark .parametrize (
@@ -90,28 +90,28 @@ def test_set_utc_if_timezone_is_missing_sets_timezone(self):
9090 (
9191 "2021-03-13T11:23:13Z" ,
9292 "ISO8601" ,
93- ZoneInfo ( " UTC" ) ,
93+ UTC ,
9494 "UTC" ,
9595 {"year" : 2021 , "month" : 3 , "day" : 13 , "hour" : 11 , "minute" : 23 , "second" : 13 },
9696 ),
9797 (
9898 "2021-03-13T11:23:13+01" ,
9999 "ISO8601" ,
100- ZoneInfo ( " UTC" ) ,
100+ UTC ,
101101 "UTC+01:00" ,
102102 {"year" : 2021 , "month" : 3 , "day" : 13 , "hour" : 11 , "minute" : 23 , "second" : 13 },
103103 ),
104104 (
105105 "2021-03-13T11:23:13" ,
106106 "ISO8601" ,
107- ZoneInfo ( " UTC" ) ,
107+ UTC ,
108108 "UTC" ,
109109 {"year" : 2021 , "month" : 3 , "day" : 13 , "hour" : 11 , "minute" : 23 , "second" : 13 },
110110 ),
111111 (
112112 "2021 03 13 - 11:23:13" ,
113113 "%Y %m %d - %H:%M:%S" ,
114- ZoneInfo ( " UTC" ) ,
114+ UTC ,
115115 "UTC" ,
116116 {"year" : 2021 , "month" : 3 , "day" : 13 , "hour" : 11 , "minute" : 23 , "second" : 13 },
117117 ),
@@ -132,7 +132,7 @@ def test_set_utc_if_timezone_is_missing_sets_timezone(self):
132132 (
133133 "03 13 - 11:23:13" ,
134134 "%m %d - %H:%M:%S" ,
135- ZoneInfo ( " UTC" ) ,
135+ UTC ,
136136 "UTC" ,
137137 {
138138 "year" : datetime .now ().year ,
@@ -159,7 +159,7 @@ def test_parse_datetime_replaces_timezone_if_it_does_not_exist_in_string(
159159 (
160160 "1615634593" ,
161161 "UNIX" ,
162- ZoneInfo ( " UTC" ) ,
162+ UTC ,
163163 "UTC" ,
164164 {"year" : 2021 , "month" : 3 , "day" : 13 , "hour" : 11 , "minute" : 23 , "second" : 13 },
165165 ),
0 commit comments