diff options
author | Alexander Belopolsky <alexander.belopolsky@gmail.com> | 2010-07-05 17:57:31 (GMT) |
---|---|---|
committer | Alexander Belopolsky <alexander.belopolsky@gmail.com> | 2010-07-05 17:57:31 (GMT) |
commit | d87e932f515c49d39b45ccc28f4c45de5f8b3346 (patch) | |
tree | 860338da83fa4d840815301a1d4ad4b0a49e692f | |
parent | b0f0991cdb584626c4cecdc307caacd4a6b5c2c0 (diff) | |
download | cpython-d87e932f515c49d39b45ccc28f4c45de5f8b3346.zip cpython-d87e932f515c49d39b45ccc28f4c45de5f8b3346.tar.gz cpython-d87e932f515c49d39b45ccc28f4c45de5f8b3346.tar.bz2 |
Added two more test cases for datetime
-rw-r--r-- | Lib/test/test_datetime.py | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/Lib/test/test_datetime.py b/Lib/test/test_datetime.py index 4423d9b..c12bfb2 100644 --- a/Lib/test/test_datetime.py +++ b/Lib/test/test_datetime.py @@ -881,6 +881,7 @@ class TestDate(HarmlessMixedComparison, unittest.TestCase): def test_computations(self): a = self.theclass(2002, 1, 31) b = self.theclass(1956, 1, 31) + c = self.theclass(2001,2,1) diff = a-b self.assertEqual(diff.days, 46*365 + len(range(1956, 2002, 4))) @@ -906,6 +907,7 @@ class TestDate(HarmlessMixedComparison, unittest.TestCase): self.assertEqual(a - (a + day), -day) self.assertEqual(a - (a - week), week) self.assertEqual(a - (a - day), day) + self.assertEqual(c - (c - day), day) # Add/sub ints or floats should be illegal for i in 1, 1.0: @@ -1347,6 +1349,10 @@ class TestDate(HarmlessMixedComparison, unittest.TestCase): for month_byte in b'9', b'\0', b'\r', b'\xff': self.assertRaises(TypeError, self.theclass, base[:2] + month_byte + base[3:]) + # Good bytes, but bad tzinfo: + self.assertRaises(TypeError, self.theclass, + bytes([1] * len(base)), 'EST') + for ord_byte in range(1, 13): # This shouldn't blow up because of the month byte alone. If # the implementation changes to do more-careful checking, it may |