Esempio n. 1
0
def test_upgrade_pytz_timezone(key):
    pytz_zone = pytz.timezone(key)

    actual = pds_helpers.upgrade_tzinfo(pytz_zone)
    expected = get_timezone(key)

    assert actual is expected
Esempio n. 2
0
def test_upgrade_shim_timezone(key):
    shim_zone = pds.timezone(key)

    actual = pds_helpers.upgrade_tzinfo(shim_zone)
    expected = get_timezone(key)

    assert actual is expected
Esempio n. 3
0
def test_upgrade_utc(utc):
    """Tests that upgrade_zone called on UTC objects returns _compat.UTC.

    This is relevant because tz.gettz("UTC") or zoneinfo.ZoneInfo("UTC") may
    each return a tzfile-based zone, not their respective UTC singletons.
    """
    actual = pds_helpers.upgrade_tzinfo(utc)

    assert actual is UTC
Esempio n. 4
0
def test_upgrade_pytz_fixed_offset(offset_minutes):
    pytz_zone = pytz.FixedOffset(offset_minutes)

    actual = pds_helpers.upgrade_tzinfo(pytz_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
Esempio n. 5
0
def test_upgrade_tz_noop(tz):
    """Tests that non-shim, non-pytz zones are unaffected by upgrade_tzinfo."""
    actual = pds_helpers.upgrade_tzinfo(tz)

    assert actual is tz