summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorTim Peters <tim.peters@gmail.com>2003-01-02 19:35:54 (GMT)
committerTim Peters <tim.peters@gmail.com>2003-01-02 19:35:54 (GMT)
commit710fb1548ab43bcddc105c41b139b6328962de01 (patch)
tree7047ed7c552cb5cc43517e5b06dfbc7dee038a36 /Lib
parent0123139d665c02fa731511d32a31724137c8eca0 (diff)
downloadcpython-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')
-rw-r--r--Lib/test/test_datetime.py17
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,