mirror of
https://github.com/python/cpython.git
synced 2025-08-20 00:32:12 +00:00
Merged revisions 81566 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk ........ r81566 | alexander.belopolsky | 2010-05-27 16:55:27 -0400 (Thu, 27 May 2010) | 3 lines Issue #7150: Raise OverflowError if the result of adding or subtracting timedelta from date or datetime falls outside of the MINYEAR:MAXYEAR range. ........
This commit is contained in:
parent
804b9d4dac
commit
cfd6bc0395
3 changed files with 28 additions and 21 deletions
|
@ -709,15 +709,16 @@ class TestDate(HarmlessMixedComparison, unittest.TestCase):
|
|||
def test_overflow(self):
|
||||
tiny = self.theclass.resolution
|
||||
|
||||
dt = self.theclass.min + tiny
|
||||
dt -= tiny # no problem
|
||||
self.assertRaises(OverflowError, dt.__sub__, tiny)
|
||||
self.assertRaises(OverflowError, dt.__add__, -tiny)
|
||||
for delta in [tiny, timedelta(1), timedelta(2)]:
|
||||
dt = self.theclass.min + delta
|
||||
dt -= delta # no problem
|
||||
self.assertRaises(OverflowError, dt.__sub__, delta)
|
||||
self.assertRaises(OverflowError, dt.__add__, -delta)
|
||||
|
||||
dt = self.theclass.max - tiny
|
||||
dt += tiny # no problem
|
||||
self.assertRaises(OverflowError, dt.__add__, tiny)
|
||||
self.assertRaises(OverflowError, dt.__sub__, -tiny)
|
||||
dt = self.theclass.max - delta
|
||||
dt += delta # no problem
|
||||
self.assertRaises(OverflowError, dt.__add__, delta)
|
||||
self.assertRaises(OverflowError, dt.__sub__, -delta)
|
||||
|
||||
def test_fromtimestamp(self):
|
||||
import time
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue