diff options
author | Benjamin Peterson <benjamin@python.org> | 2014-03-20 23:00:35 (GMT) |
---|---|---|
committer | Benjamin Peterson <benjamin@python.org> | 2014-03-20 23:00:35 (GMT) |
commit | ee6bdc07d65d5df418ad9dc2bb7139666af9a6b2 (patch) | |
tree | adb181a1a208c65822fb533fdeae01244862f006 /Lib/test | |
parent | 265ae86414f2a70643bad4b487f07da1c2bba50a (diff) | |
download | cpython-ee6bdc07d65d5df418ad9dc2bb7139666af9a6b2.zip cpython-ee6bdc07d65d5df418ad9dc2bb7139666af9a6b2.tar.gz cpython-ee6bdc07d65d5df418ad9dc2bb7139666af9a6b2.tar.bz2 |
remove the ability of datetime.time to be considered false (closes #13936)
Diffstat (limited to 'Lib/test')
-rw-r--r-- | Lib/test/datetimetester.py | 21 |
1 files changed, 5 insertions, 16 deletions
diff --git a/Lib/test/datetimetester.py b/Lib/test/datetimetester.py index 3f3c60a..b8c6138 100644 --- a/Lib/test/datetimetester.py +++ b/Lib/test/datetimetester.py @@ -2270,13 +2270,14 @@ class TestTime(HarmlessMixedComparison, unittest.TestCase): self.assertEqual(orig, derived) def test_bool(self): + # time is always True. cls = self.theclass self.assertTrue(cls(1)) self.assertTrue(cls(0, 1)) self.assertTrue(cls(0, 0, 1)) self.assertTrue(cls(0, 0, 0, 1)) - self.assertFalse(cls(0)) - self.assertFalse(cls()) + self.assertTrue(cls(0)) + self.assertTrue(cls()) def test_replace(self): cls = self.theclass @@ -2629,7 +2630,7 @@ class TestTimeTZ(TestTime, TZInfoBase, unittest.TestCase): self.assertEqual(derived.tzname(), 'cookie') def test_more_bool(self): - # Test cases with non-None tzinfo. + # time is always True. cls = self.theclass t = cls(0, tzinfo=FixedOffset(-300, "")) @@ -2639,23 +2640,11 @@ class TestTimeTZ(TestTime, TZInfoBase, unittest.TestCase): self.assertTrue(t) t = cls(5, tzinfo=FixedOffset(300, "")) - self.assertFalse(t) + self.assertTrue(t) t = cls(23, 59, tzinfo=FixedOffset(23*60 + 59, "")) - self.assertFalse(t) - - # Mostly ensuring this doesn't overflow internally. - t = cls(0, tzinfo=FixedOffset(23*60 + 59, "")) self.assertTrue(t) - # But this should yield a value error -- the utcoffset is bogus. - t = cls(0, tzinfo=FixedOffset(24*60, "")) - self.assertRaises(ValueError, lambda: bool(t)) - - # Likewise. - t = cls(0, tzinfo=FixedOffset(-24*60, "")) - self.assertRaises(ValueError, lambda: bool(t)) - def test_replace(self): cls = self.theclass z100 = FixedOffset(100, "+100") |