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

Method _testTzFunc

tests/test_tz.py:882–895  ·  view source on GitHub ↗

This generates tests about how the behavior of a function ``func`` changes between STD and DST (e.g. utcoffset, tzname, dst). It assume that DST starts the 2nd Sunday in March and ends the 1st Sunday in November

(self, tzval, func, std_val, dst_val)

Source from the content-addressed store, hash-verified

880 return TZEnvContext(tzname_map.get(tzname, tzname))
881
882 def _testTzFunc(self, tzval, func, std_val, dst_val):
883 """
884 This generates tests about how the behavior of a function ``func``
885 changes between STD and DST (e.g. utcoffset, tzname, dst).
886
887 It assume that DST starts the 2nd Sunday in March and ends the 1st
888 Sunday in November
889 """
890 with TZEnvContext(tzval):
891 dt1 = datetime(2015, 2, 1, 12, 0, tzinfo=tz.tzlocal()) # STD
892 dt2 = datetime(2015, 5, 1, 12, 0, tzinfo=tz.tzlocal()) # DST
893
894 self.assertEqual(func(dt1), std_val)
895 self.assertEqual(func(dt2), dst_val)
896
897 def _testTzName(self, tzval, std_name, dst_name):
898 func = datetime.tzname

Callers 3

_testTzNameMethod · 0.95
_testOffsetMethod · 0.95
_testDSTMethod · 0.95

Calls 2

TZEnvContextClass · 0.85
funcFunction · 0.85

Tested by

no test coverage detected