mirror of
https://github.com/python/cpython.git
synced 2026-01-26 21:03:34 +00:00
gh-80620: Fix test_time.test_gmtime() for 32-bit time_t (#143861)
This commit is contained in:
parent
f5685a266b
commit
1597d00d96
@ -192,18 +192,29 @@ class TimeTestCase(unittest.TestCase):
|
||||
# (tm_year, tm_mon, tm_mday,
|
||||
# tm_hour, tm_min, tm_sec,
|
||||
# tm_wday, tm_yday)
|
||||
for t, expected in (
|
||||
tests = [
|
||||
(-13262400, (1969, 7, 31, 12, 0, 0, 3, 212)),
|
||||
(-6177600, (1969, 10, 21, 12, 0, 0, 1, 294)),
|
||||
# non-leap years (pre epoch)
|
||||
(-2203891200, (1900, 3, 1, 0, 0, 0, 3, 60)),
|
||||
(-2203977600, (1900, 2, 28, 0, 0, 0, 2, 59)),
|
||||
(-5359564800, (1800, 3, 1, 0, 0, 0, 5, 60)),
|
||||
(-5359651200, (1800, 2, 28, 0, 0, 0, 4, 59)),
|
||||
# leap years (pre epoch)
|
||||
(-2077660800, (1904, 3, 1, 0, 0, 0, 1, 61)),
|
||||
(-2077833600, (1904, 2, 28, 0, 0, 0, 6, 59)),
|
||||
):
|
||||
]
|
||||
|
||||
try:
|
||||
from _testinternalcapi import SIZEOF_TIME_T
|
||||
except ImportError:
|
||||
pass
|
||||
else:
|
||||
if SIZEOF_TIME_T >= 8:
|
||||
tests.extend((
|
||||
# non-leap years (pre epoch)
|
||||
(-2203891200, (1900, 3, 1, 0, 0, 0, 3, 60)),
|
||||
(-2203977600, (1900, 2, 28, 0, 0, 0, 2, 59)),
|
||||
(-5359564800, (1800, 3, 1, 0, 0, 0, 5, 60)),
|
||||
(-5359651200, (1800, 2, 28, 0, 0, 0, 4, 59)),
|
||||
))
|
||||
|
||||
for t, expected in tests:
|
||||
with self.subTest(t=t, expected=expected):
|
||||
res = time.gmtime(t)
|
||||
self.assertEqual(tuple(res)[:8], expected, res)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user