[Python-checkins] python/dist/src/Lib/test test_datetime.py,1.19,1.20

tim_one@users.sourceforge.net tim_one@users.sourceforge.net
Thu, 02 Jan 2003 11:35:56 -0800


Update of /cvsroot/python/python/dist/src/Lib/test
In directory sc8-pr-cvs1:/tmp/cvs-serv9800/Lib/test

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).


Index: test_datetime.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_datetime.py,v
retrieving revision 1.19
retrieving revision 1.20
diff -C2 -d -r1.19 -r1.20
*** test_datetime.py	1 Jan 2003 21:51:36 -0000	1.19
--- test_datetime.py	2 Jan 2003 19:35:53 -0000	1.20
***************
*** 2592,2595 ****
--- 2592,2597 ----
      dstoff = datetimetz(2002, 10, 27, 2)
  
+     theclass = datetimetz
+ 
      # Check a time that's inside DST.
      def checkinside(self, dt, tz, utc, dston, dstoff):
***************
*** 2729,2732 ****
--- 2731,2749 ----
          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():