3030
3131import datetime
3232import functools
33- import contextlib
3433from unittest import skipIf
3534from unittest .mock import patch
3635
37- try :
38- import pytz
39- except ImportError :
40- pytz = None
41-
4236try :
4337 import zoneinfo
4438except ImportError :
@@ -64,35 +58,6 @@ def newf(self):
6458class GeographyTimezoneTestCase (PluginTestCase ):
6559 plugins = ("Geography" ,)
6660
67- @skipIf (not pytz , "pytz is not available" )
68- @mock
69- def testTimezonePytz (self ):
70- tz = pytz .timezone ("Europe/Paris" )
71- with patch .object (wikidata , "timezone_from_uri" , return_value = tz ):
72- self .assertRegexp (
73- "timezone Foo Bar" , r"Europe/Paris \(currently UTC\+[12]\)"
74- )
75-
76- tz = pytz .timezone ("America/New_York" )
77- with patch .object (wikidata , "timezone_from_uri" , return_value = tz ):
78- self .assertRegexp (
79- "timezone New York" , r"America/New_York \(currently UTC-[45]\)"
80- )
81-
82- tz = pytz .timezone ("America/St_Johns" )
83- with patch .object (wikidata , "timezone_from_uri" , return_value = tz ):
84- self .assertRegexp (
85- "timezone Newfoundland" ,
86- r"America/St_Johns \(currently UTC-[23]:30\)" ,
87- )
88-
89- tz = pytz .timezone ("Asia/Kolkata" )
90- with patch .object (wikidata , "timezone_from_uri" , return_value = tz ):
91- self .assertRegexp (
92- "timezone Delhi" , r"Asia/Kolkata \(currently UTC\+5:30\)"
93- )
94-
95- @skipIf (not zoneinfo , "Python is older than 3.9" )
9661 @mock
9762 def testTimezoneZoneinfo (self ):
9863 tz = zoneinfo .ZoneInfo ("Europe/Paris" )
@@ -120,7 +85,6 @@ def testTimezoneZoneinfo(self):
12085 "timezone Delhi" , r"Asia/Kolkata \(currently UTC\+5:30\)"
12186 )
12287
123- @skipIf (not zoneinfo , "Python is older than 3.9" )
12488 @mock
12589 def testTimezoneAbsolute (self ):
12690 tz = datetime .timezone (datetime .timedelta (hours = 4 ))
@@ -150,23 +114,13 @@ def testTimezoneIntegration(self):
150114class GeographyLocaltimeTestCase (PluginTestCase ):
151115 plugins = ("Geography" ,)
152116
153- @skipIf (not pytz , "pytz is not available" )
154- @mock
155- def testLocaltimePytz (self ):
156- tz = pytz .timezone ("Europe/Paris" )
157-
158- with patch .object (wikidata , "timezone_from_uri" , return_value = tz ):
159- self .assertRegexp ("localtime Foo Bar" , r".*\+0[12]00$" )
160-
161- @skipIf (not zoneinfo , "Python is older than 3.9" )
162117 @mock
163118 def testLocaltimeZoneinfo (self ):
164119 tz = zoneinfo .ZoneInfo ("Europe/Paris" )
165120
166121 with patch .object (wikidata , "timezone_from_uri" , return_value = tz ):
167122 self .assertRegexp ("localtime Foo Bar" , r".*\+0[12]00$" )
168123
169- @skipIf (not zoneinfo , "Python is older than 3.9" )
170124 @mock
171125 def testLocaltimeAbsolute (self ):
172126 tz = datetime .timezone (datetime .timedelta (hours = 4 ))
0 commit comments