diff options
author | Alexander Belopolsky <alexander.belopolsky@gmail.com> | 2010-05-27 21:42:58 (GMT) |
---|---|---|
committer | Alexander Belopolsky <alexander.belopolsky@gmail.com> | 2010-05-27 21:42:58 (GMT) |
commit | f03a6164321d37f05dbf93023ce6114f0cdbd910 (patch) | |
tree | 26923f66e17a7803188590c13c10589e26057ea0 /Lib/test/test_datetime.py | |
parent | 1ed21db0f56944af5fe31ab509f6662e012f1df3 (diff) | |
download | cpython-f03a6164321d37f05dbf93023ce6114f0cdbd910.zip cpython-f03a6164321d37f05dbf93023ce6114f0cdbd910.tar.gz cpython-f03a6164321d37f05dbf93023ce6114f0cdbd910.tar.bz2 |
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.
........
Diffstat (limited to 'Lib/test/test_datetime.py')
-rw-r--r-- | Lib/test/test_datetime.py | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/Lib/test/test_datetime.py b/Lib/test/test_datetime.py index 892e68f..b751820 100644 --- a/Lib/test/test_datetime.py +++ b/Lib/test/test_datetime.py @@ -761,15 +761,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) - - dt = self.theclass.max - tiny - dt += tiny # no problem - self.assertRaises(OverflowError, dt.__add__, tiny) - self.assertRaises(OverflowError, dt.__sub__, -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 - delta + dt += delta # no problem + self.assertRaises(OverflowError, dt.__add__, delta) + self.assertRaises(OverflowError, dt.__sub__, -delta) def test_fromtimestamp(self): import time |