Skip to content

Commit 47aff70

Browse files
authored
ci: if tzdata not available, skip comparing to ZoneInfo (#1200)
1 parent c2c90fd commit 47aff70

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

tests/test_tzinfo.py

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
from pydantic_core import SchemaValidator, TzInfo, core_schema
99

1010
if sys.version_info >= (3, 9):
11-
from zoneinfo import ZoneInfo
11+
from zoneinfo import ZoneInfo, ZoneInfoNotFoundError
1212

1313

1414
class _ALWAYS_EQ:
@@ -174,10 +174,17 @@ def test_comparison(self):
174174
estdatetime = self.DT.replace(tzinfo=timezone(-timedelta(hours=5)))
175175
self.assertTrue(self.EST == estdatetime.tzinfo)
176176
self.assertTrue(tz > estdatetime.tzinfo)
177+
177178
if sys.version_info >= (3, 9) and sys.platform == 'linux':
178-
self.assertFalse(tz == ZoneInfo('Europe/London'))
179-
with self.assertRaises(TypeError):
180-
tz > ZoneInfo('Europe/London')
179+
try:
180+
europe_london = ZoneInfo('Europe/London')
181+
except ZoneInfoNotFoundError:
182+
# tz data not available
183+
pass
184+
else:
185+
self.assertFalse(tz == europe_london)
186+
with self.assertRaises(TypeError):
187+
tz > europe_london
181188

182189
def test_copy(self):
183190
for tz in self.ACDT, self.EST:

0 commit comments

Comments
 (0)