MCPcopy Index your code
hub / github.com/RustPython/RustPython / test_dst

Method test_dst

Lib/test/datetimetester.py:6313–6337  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

6311 'datetime.datetime(1, 1, 1, 0, 0, fold=1)')
6312
6313 def test_dst(self):
6314 # Let's first establish that things work in regular times.
6315 dt_summer = datetime(2002, 10, 27, 1, tzinfo=Eastern2) - timedelta.resolution
6316 dt_winter = datetime(2002, 10, 27, 2, tzinfo=Eastern2)
6317 self.assertEqual(dt_summer.dst(), HOUR)
6318 self.assertEqual(dt_winter.dst(), ZERO)
6319 # The disambiguation flag is ignored
6320 self.assertEqual(dt_summer.replace(fold=1).dst(), HOUR)
6321 self.assertEqual(dt_winter.replace(fold=1).dst(), ZERO)
6322
6323 # Pick local time in the fold.
6324 for minute in [0, 30, 59]:
6325 dt = datetime(2002, 10, 27, 1, minute, tzinfo=Eastern2)
6326 # With fold=0 (the default) it is in DST.
6327 self.assertEqual(dt.dst(), HOUR)
6328 # With fold=1 it is in STD.
6329 self.assertEqual(dt.replace(fold=1).dst(), ZERO)
6330
6331 # Pick local time in the gap.
6332 for minute in [0, 30, 59]:
6333 dt = datetime(2002, 4, 7, 2, minute, tzinfo=Eastern2)
6334 # With fold=0 (the default) it is in STD.
6335 self.assertEqual(dt.dst(), ZERO)
6336 # With fold=1 it is in DST.
6337 self.assertEqual(dt.replace(fold=1).dst(), HOUR)
6338
6339
6340 def test_utcoffset(self):

Callers

nothing calls this directly

Calls 4

datetimeClass · 0.90
assertEqualMethod · 0.45
dstMethod · 0.45
replaceMethod · 0.45

Tested by

no test coverage detected