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

Method test_folds

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

Source from the content-addressed store, hash-verified

6848 (b.replace(tzinfo=None), b.fold, id(b.tzinfo)))
6849
6850 def test_folds(self):
6851 tz = self.tz
6852 for dt, shift in tz.folds():
6853 for x in [0 * shift, 0.5 * shift, shift - timedelta.resolution]:
6854 udt = dt + x
6855 ldt = tz.fromutc(udt.replace(tzinfo=tz))
6856 self.assertEqual(ldt.fold, 1)
6857 adt = udt.replace(tzinfo=timezone.utc).astimezone(tz)
6858 self.assertEquivDatetimes(adt, ldt)
6859 utcoffset = ldt.utcoffset()
6860 self.assertEqual(ldt.replace(tzinfo=None), udt + utcoffset)
6861 # Round trip
6862 self.assertEquivDatetimes(ldt.astimezone(timezone.utc),
6863 udt.replace(tzinfo=timezone.utc))
6864
6865
6866 for x in [-timedelta.resolution, shift]:
6867 udt = dt + x
6868 udt = udt.replace(tzinfo=tz)
6869 ldt = tz.fromutc(udt)
6870 self.assertEqual(ldt.fold, 0)
6871
6872 def test_gaps(self):
6873 tz = self.tz

Callers

nothing calls this directly

Calls 7

assertEquivDatetimesMethod · 0.95
foldsMethod · 0.80
astimezoneMethod · 0.80
fromutcMethod · 0.45
replaceMethod · 0.45
assertEqualMethod · 0.45
utcoffsetMethod · 0.45

Tested by

no test coverage detected