Daylight savings suck!

This commit is contained in:
Pedro Algarvio 2024-03-12 13:58:55 +00:00
parent 58d8435758
commit d6e72e1f54
No known key found for this signature in database
GPG key ID: BB36BF6584A298FF

View file

@ -156,6 +156,9 @@ def test_get_offset(timezone):
"""
Test timezone.get_offset
"""
pytz = pytest.importorskip("pytz")
now = datetime.datetime.now(tz=pytz.UTC)
ret = timezone.set_zone("Pacific/Wake")
assert ret
ret = timezone.get_offset()
@ -166,7 +169,11 @@ def test_get_offset(timezone):
assert ret
ret = timezone.get_offset()
assert isinstance(ret, str)
assert ret == "-0800"
if now.astimezone(pytz.timezone("America/Los_Angeles")).dst():
assert ret == "-0700"
else:
assert ret == "-0800"
@pytest.mark.usefixtures("_reset_zone")