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

Method test_timestamp_limits

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

Source from the content-addressed store, hash-verified

2862 self.assertEqual(t.microsecond, 7812)
2863
2864 def test_timestamp_limits(self):
2865 with self.subTest("minimum UTC"):
2866 min_dt = self.theclass.min.replace(tzinfo=timezone.utc)
2867 min_ts = min_dt.timestamp()
2868
2869 # This test assumes that datetime.min == 0000-01-01T00:00:00.00
2870 # If that assumption changes, this value can change as well
2871 self.assertEqual(min_ts, -62135596800)
2872
2873 with self.subTest("maximum UTC"):
2874 # Zero out microseconds to avoid rounding issues
2875 max_dt = self.theclass.max.replace(tzinfo=timezone.utc,
2876 microsecond=0)
2877 max_ts = max_dt.timestamp()
2878
2879 # This test assumes that datetime.max == 9999-12-31T23:59:59.999999
2880 # If that assumption changes, this value can change as well
2881 self.assertEqual(max_ts, 253402300799.0)
2882
2883 @unittest.skipIf(sys.platform == "win32", "Windows doesn't support min timestamp")
2884 def test_fromtimestamp_limits(self):

Callers

nothing calls this directly

Calls 4

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

Tested by

no test coverage detected