MCPcopy Create free account
hub / github.com/dateutil/dateutil / TestTZVar

Class TestTZVar

tests/test_parser.py:890–924  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

888
889@pytest.mark.skipif(IS_WIN, reason="Windows does not use TZ var")
890class TestTZVar(object):
891 def test_parse_unambiguous_nonexistent_local(self):
892 # When dates are specified "EST" even when they should be "EDT" in the
893 # local time zone, we should still assign the local time zone
894 with TZEnvContext('EST+5EDT,M3.2.0/2,M11.1.0/2'):
895 dt_exp = datetime(2011, 8, 1, 12, 30, tzinfo=tz.tzlocal())
896 dt = parse('2011-08-01T12:30 EST')
897
898 assert dt.tzname() == 'EDT'
899 assert dt == dt_exp
900
901 def test_tzlocal_in_gmt(self):
902 # GH #318
903 with TZEnvContext('GMT0BST,M3.5.0,M10.5.0'):
904 # This is an imaginary datetime in tz.tzlocal() but should still
905 # parse using the GMT-as-alias-for-UTC rule
906 dt = parse('2004-05-01T12:00 GMT')
907 dt_exp = datetime(2004, 5, 1, 12, tzinfo=tz.UTC)
908
909 assert dt == dt_exp
910
911 def test_tzlocal_parse_fold(self):
912 # One manifestion of GH #318
913 with TZEnvContext('EST+5EDT,M3.2.0/2,M11.1.0/2'):
914 dt_exp = datetime(2011, 11, 6, 1, 30, tzinfo=tz.tzlocal())
915 dt_exp = tz.enfold(dt_exp, fold=1)
916 dt = parse('2011-11-06T01:30 EST')
917
918 # Because this is ambiguous, until `tz.tzlocal() is tz.tzlocal()`
919 # we'll just check the attributes we care about rather than
920 # dt == dt_exp
921 assert dt.tzname() == dt_exp.tzname()
922 assert dt.replace(tzinfo=None) == dt_exp.replace(tzinfo=None)
923 assert getattr(dt, 'fold') == getattr(dt_exp, 'fold')
924 assert dt.astimezone(tz.UTC) == dt_exp.astimezone(tz.UTC)
925
926
927def test_parse_tzinfos_fold():

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected