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

Method test_gaps

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

Source from the content-addressed store, hash-verified

6683 self.assertEqual(ldt.fold, 0)
6684
6685 def test_gaps(self):
6686 tz = self.tz
6687 for dt, shift in tz.gaps():
6688 for x in [0 * shift, 0.5 * shift, shift - timedelta.resolution]:
6689 udt = dt + x
6690 udt = udt.replace(tzinfo=tz)
6691 ldt = tz.fromutc(udt)
6692 self.assertEqual(ldt.fold, 0)
6693 adt = udt.replace(tzinfo=timezone.utc).astimezone(tz)
6694 self.assertEquivDatetimes(adt, ldt)
6695 utcoffset = ldt.utcoffset()
6696 self.assertEqual(ldt.replace(tzinfo=None), udt.replace(tzinfo=None) + utcoffset)
6697 # Create a local time inside the gap
6698 ldt = tz.fromutc(dt.replace(tzinfo=tz)) - shift + x
6699 self.assertLess(ldt.replace(fold=1).utcoffset(),
6700 ldt.replace(fold=0).utcoffset(),
6701 "At %s." % ldt)
6702
6703 for x in [-timedelta.resolution, shift]:
6704 udt = dt + x
6705 ldt = tz.fromutc(udt.replace(tzinfo=tz))
6706 self.assertEqual(ldt.fold, 0)
6707
6708 @classmethod
6709 @contextlib.contextmanager

Callers

nothing calls this directly

Calls 8

assertEquivDatetimesMethod · 0.95
gapsMethod · 0.80
astimezoneMethod · 0.80
replaceMethod · 0.45
fromutcMethod · 0.45
assertEqualMethod · 0.45
utcoffsetMethod · 0.45
assertLessMethod · 0.45

Tested by

no test coverage detected