Ejemplo n.º 1
0
def test_can_coerce_and_raise_UnknownTimeZoneError_or_ValueError(backend):
    tzcol = TimezoneType(backend=backend)
    exceptions = (ValueError, pytz.exceptions.UnknownTimeZoneError,
                  zoneinfo.ZoneInfoNotFoundError)
    with pytest.raises(exceptions):
        tzcol._coerce('SolarSystem/Mars')
    with pytest.raises(exceptions):
        tzcol._coerce('')
Ejemplo n.º 2
0
def test_can_coerce_None(backend):
    tzcol = TimezoneType(backend=backend)
    assert tzcol._coerce(None) is None
Ejemplo n.º 3
0
def test_can_coerce_and_raise_UnknownTimeZoneError_or_ValueError(backend):
    tzcol = TimezoneType(backend=backend)
    with pytest.raises((ValueError, pytz.exceptions.UnknownTimeZoneError)):
        tzcol._coerce('SolarSystem/Mars')
    with pytest.raises((ValueError, pytz.exceptions.UnknownTimeZoneError)):
        tzcol._coerce('')
Ejemplo n.º 4
0
def test_can_coerce_string_for_dateutil_zone(zone):
    tzcol = TimezoneType(backend='dateutil')
    assert isinstance(tzcol._coerce(zone), tzfile)
Ejemplo n.º 5
0
def test_can_coerce_string_for_pytz_zone(zone):
    tzcol = TimezoneType(backend='pytz')
    assert tzcol._coerce(zone).zone == zone
Ejemplo n.º 6
0
def test_can_coerce_pytz_StaticTzInfo():
    tzcol = TimezoneType(backend='pytz')
    tz = pytz.timezone('Pacific/Truk')
    assert isinstance(tz, pytz.tzfile.StaticTzInfo)
    assert tzcol._coerce(tz) is tz
Ejemplo n.º 7
0
def test_can_coerce_pytz_DstTzInfo():
    tzcol = TimezoneType(backend='pytz')
    tz = pytz.timezone('America/New_York')
    assert isinstance(tz, pytz.tzfile.DstTzInfo)
    assert tzcol._coerce(tz) is tz
Ejemplo n.º 8
0
def test_can_coerce_None(backend):
    tzcol = TimezoneType(backend=backend)
    assert tzcol._coerce(None) is None
Ejemplo n.º 9
0
def test_can_coerce_and_raise_UnknownTimeZoneError_or_ValueError(backend):
    tzcol = TimezoneType(backend=backend)
    with pytest.raises((ValueError, pytz.exceptions.UnknownTimeZoneError)):
        tzcol._coerce('SolarSystem/Mars')
    with pytest.raises((ValueError, pytz.exceptions.UnknownTimeZoneError)):
        tzcol._coerce('')
Ejemplo n.º 10
0
def test_can_coerce_string_for_dateutil_zone(zone):
    tzcol = TimezoneType(backend='dateutil')
    assert isinstance(tzcol._coerce(zone), tzfile)
Ejemplo n.º 11
0
def test_can_coerce_string_for_pytz_zone(zone):
    tzcol = TimezoneType(backend='pytz')
    assert tzcol._coerce(zone).zone == zone
Ejemplo n.º 12
0
def test_can_coerce_pytz_StaticTzInfo():
    tzcol = TimezoneType(backend='pytz')
    tz = pytz.timezone('Pacific/Truk')
    assert isinstance(tz, pytz.tzfile.StaticTzInfo)
    assert tzcol._coerce(tz) is tz
Ejemplo n.º 13
0
def test_can_coerce_pytz_DstTzInfo():
    tzcol = TimezoneType(backend='pytz')
    tz = pytz.timezone('America/New_York')
    assert isinstance(tz, pytz.tzfile.DstTzInfo)
    assert tzcol._coerce(tz) is tz
Ejemplo n.º 14
0
def test_can_coerce_string_for_zoneinfo_zone(zone):
    tzcol = TimezoneType(backend='zoneinfo')
    assert str(tzcol._coerce(zone)) == zone