[Python-checkins] python/dist/src/Lib/test test_datetime.py,1.4,1.5

tim_one@users.sourceforge.net tim_one@users.sourceforge.net
Sat, 21 Dec 2002 09:44:09 -0800


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

Modified Files:
	test_datetime.py 
Log Message:
Added test to ensure that non-string result from dst() raises TypeError.


Index: test_datetime.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_datetime.py,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** test_datetime.py	21 Dec 2002 05:04:42 -0000	1.4
--- test_datetime.py	21 Dec 2002 17:44:07 -0000	1.5
***************
*** 1562,1565 ****
--- 1562,1571 ----
                                       "23:59 %Z='%z %Z %%z%%Z' %z='-2359'")
  
+         # Check that an invalid tzname result raises an exception.
+         class Badtzname(tzinfo):
+             def tzname(self, dt): return 42
+         t = timetz(2, 3, 4, tzinfo=Badtzname())
+         self.assertEqual(t.strftime("%H:%M:%S"), "02:03:04")
+         self.assertRaises(TypeError, t.strftime, "%Z")
  
      def test_hash_edge_cases(self):