MCPcopy Index your code
hub / github.com/python/cpython / test_dst

Method test_dst

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

Source from the content-addressed store, hash-verified

6498 'datetime.datetime(1, 1, 1, 0, 0, fold=1)')
6499
6500 def test_dst(self):
6501 # Let's first establish that things work in regular times.
6502 dt_summer = datetime(2002, 10, 27, 1, tzinfo=Eastern2) - timedelta.resolution
6503 dt_winter = datetime(2002, 10, 27, 2, tzinfo=Eastern2)
6504 self.assertEqual(dt_summer.dst(), HOUR)
6505 self.assertEqual(dt_winter.dst(), ZERO)
6506 # The disambiguation flag is ignored
6507 self.assertEqual(dt_summer.replace(fold=1).dst(), HOUR)
6508 self.assertEqual(dt_winter.replace(fold=1).dst(), ZERO)
6509
6510 # Pick local time in the fold.
6511 for minute in [0, 30, 59]:
6512 dt = datetime(2002, 10, 27, 1, minute, tzinfo=Eastern2)
6513 # With fold=0 (the default) it is in DST.
6514 self.assertEqual(dt.dst(), HOUR)
6515 # With fold=1 it is in STD.
6516 self.assertEqual(dt.replace(fold=1).dst(), ZERO)
6517
6518 # Pick local time in the gap.
6519 for minute in [0, 30, 59]:
6520 dt = datetime(2002, 4, 7, 2, minute, tzinfo=Eastern2)
6521 # With fold=0 (the default) it is in STD.
6522 self.assertEqual(dt.dst(), ZERO)
6523 # With fold=1 it is in DST.
6524 self.assertEqual(dt.replace(fold=1).dst(), HOUR)
6525
6526
6527 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