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

Class TestTZVar

tests/test_parser.py:893–927  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected