[Zope3-checkins] CVS: Zope3/src/datetime/tests - test_datetime.py:1.13
Tim Peters
tim.one@comcast.net
Thu, 2 Jan 2003 14:27:16 -0500
Update of /cvs-repository/Zope3/src/datetime/tests
In directory cvs.zope.org:/tmp/cvs-serv4901/src/datetime/tests
Modified Files:
test_datetime.py
Log Message:
astimezone() internals: if utcoffset() returns a duration, complain if
dst() returns None (instead of treating that as 0).
=== Zope3/src/datetime/tests/test_datetime.py 1.12 => 1.13 ===
--- Zope3/src/datetime/tests/test_datetime.py:1.12 Wed Jan 1 15:56:21 2003
+++ Zope3/src/datetime/tests/test_datetime.py Thu Jan 2 14:27:14 2003
@@ -2601,6 +2601,8 @@
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)
@@ -2738,6 +2740,21 @@
expected = self.dston.replace(hour=1)
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')