def test_upgrade_shim_fixed_offset(offset_minutes): shim_zone = pds.fixed_offset_timezone(offset_minutes) actual = pds_helpers.upgrade_tzinfo(shim_zone) expected = get_fixed_timezone(offset_minutes) # get_fixed_timezone doesn't do any caching, so the fixed offsets aren't # necessarily going to be singletons. assert actual == expected
def test_localize_fixed_offset(dt, offset): pytz_zone = pytz.FixedOffset(offset) shim_zone = pds.fixed_offset_timezone(offset) dt_pytz = pytz_zone.localize(dt) with pytest.warns(pds.PytzUsageWarning): dt_shim = shim_zone.localize(dt) assert dt_pytz == dt_shim assert dt_pytz.utcoffset() == dt_shim.utcoffset()
def test_str_fixed_offset(minutes): shim_zone = pds.fixed_offset_timezone(minutes) assert str(shim_zone) == repr(shim_zone)
def test_fixed_offset_utc(): """Tests that fixed_offset_timezone(0) always returns UTC.""" assert pds.fixed_offset_timezone(0) is pds.UTC
def test_invalid_fixed_offsets(offset): with pytest.raises(ValueError): pds.fixed_offset_timezone(offset)