diff options
author | Tim Peters <tim.peters@gmail.com> | 2003-01-02 19:35:54 (GMT) |
---|---|---|
committer | Tim Peters <tim.peters@gmail.com> | 2003-01-02 19:35:54 (GMT) |
commit | 710fb1548ab43bcddc105c41b139b6328962de01 (patch) | |
tree | 7047ed7c552cb5cc43517e5b06dfbc7dee038a36 /Lib/test | |
parent | 0123139d665c02fa731511d32a31724137c8eca0 (diff) | |
download | cpython-710fb1548ab43bcddc105c41b139b6328962de01.zip cpython-710fb1548ab43bcddc105c41b139b6328962de01.tar.gz cpython-710fb1548ab43bcddc105c41b139b6328962de01.tar.bz2 |
astimezone() internals: if utcoffset() returns a duration, complain if
dst() returns None (instead of treating that as 0).
Diffstat (limited to 'Lib/test')
-rw-r--r-- | Lib/test/test_datetime.py | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/Lib/test/test_datetime.py b/Lib/test/test_datetime.py index 4fe2ad2..29f81f1 100644 --- a/Lib/test/test_datetime.py +++ b/Lib/test/test_datetime.py @@ -2591,6 +2591,8 @@ class TestTimezoneConversions(unittest.TestCase): dston = datetimetz(2002, 4, 7, 2) dstoff = datetimetz(2002, 10, 27, 2) + theclass = datetimetz + # Check a time that's inside DST. def checkinside(self, dt, tz, utc, dston, dstoff): self.assertEqual(dt.dst(), HOUR) @@ -2729,6 +2731,21 @@ class TestTimezoneConversions(unittest.TestCase): got = sixutc.astimezone(Eastern).astimezone(None) self.assertEqual(expected, got) + def test_bogus_dst(self): + class ok(tzinfo): + def utcoffset(self, dt): return HOUR + def dst(self, dt): return HOUR + + now = self.theclass.now().replace(tzinfo=utc_real) + # Doesn't blow up. + now.astimezone(ok()) + + # Does blow up. + class notok(ok): + def dst(self, dt): return None + self.assertRaises(ValueError, now.astimezone, notok()) + + def test_suite(): allsuites = [unittest.makeSuite(klass, 'test') for klass in (TestModule, |