diff options
| author | Alexander Belopolsky <alexander.belopolsky@gmail.com> | 2011-01-11 01:21:25 (GMT) |
|---|---|---|
| committer | Alexander Belopolsky <alexander.belopolsky@gmail.com> | 2011-01-11 01:21:25 (GMT) |
| commit | b7d40d170248fb2419d068c6b0647ed262e3427f (patch) | |
| tree | 371979019361255b821b548001f2e24821bce658 /Lib/test/test_time.py | |
| parent | 723447958070683deb3ff32d793c4bb731d325b7 (diff) | |
| download | cpython-b7d40d170248fb2419d068c6b0647ed262e3427f.zip cpython-b7d40d170248fb2419d068c6b0647ed262e3427f.tar.gz cpython-b7d40d170248fb2419d068c6b0647ed262e3427f.tar.bz2 | |
Issue #1726687: time.mktime() will now correctly compute value one
second before epoch. Original patch by Peter Wang, reported by Martin
Blais.
Diffstat (limited to 'Lib/test/test_time.py')
| -rw-r--r-- | Lib/test/test_time.py | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/Lib/test/test_time.py b/Lib/test/test_time.py index baabfbb..d649232 100644 --- a/Lib/test/test_time.py +++ b/Lib/test/test_time.py @@ -339,6 +339,19 @@ class _Test4dYear(_BaseYearTest): self.assertEqual(self.yearstr(-1234), '-1234') self.assertEqual(self.yearstr(-123456), '-123456') + + def test_mktime(self): + # Issue #1726687 + for t in (-2, -1, 0, 1): + try: + tt = time.localtime(t) + except (OverflowError, ValueError): + pass + self.assertEqual(time.mktime(tt), t) + # Hopefully year = -1 is enough to make OS mktime fail + self.assertRaises(OverflowError, time.mktime, + (-1, 1, 1, 0, 0, 0, -1, -1, -1)) + class TestAsctimeAccept2dYear(_TestAsctimeYear, _Test2dYear): pass |
