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

Method test_timestamp_limits

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

Source from the content-addressed store, hash-verified

2723 self.assertEqual(t.microsecond, 7812)
2724
2725 def test_timestamp_limits(self):
2726 with self.subTest("minimum UTC"):
2727 min_dt = self.theclass.min.replace(tzinfo=timezone.utc)
2728 min_ts = min_dt.timestamp()
2729
2730 # This test assumes that datetime.min == 0000-01-01T00:00:00.00
2731 # If that assumption changes, this value can change as well
2732 self.assertEqual(min_ts, -62135596800)
2733
2734 with self.subTest("maximum UTC"):
2735 # Zero out microseconds to avoid rounding issues
2736 max_dt = self.theclass.max.replace(tzinfo=timezone.utc,
2737 microsecond=0)
2738 max_ts = max_dt.timestamp()
2739
2740 # This test assumes that datetime.max == 9999-12-31T23:59:59.999999
2741 # If that assumption changes, this value can change as well
2742 self.assertEqual(max_ts, 253402300799.0)
2743
2744 def test_fromtimestamp_limits(self):
2745 try:

Callers

nothing calls this directly

Calls 4

subTestMethod · 0.80
timestampMethod · 0.80
replaceMethod · 0.45
assertEqualMethod · 0.45

Tested by

no test coverage detected