[Zope3-checkins] CVS: Zope3/lib/python/datetime/tests - test_datetime.py:1.4

Tim Peters tim.one@comcast.net
Sat, 21 Dec 2002 12:42:03 -0500


Update of /cvs-repository/Zope3/lib/python/datetime/tests
In directory cvs.zope.org:/tmp/cvs-serv17133/lib/python/datetime/tests

Modified Files:
	test_datetime.py 
Log Message:
Always catch non-string results from indirect tzinfo.dst() calls.


=== Zope3/lib/python/datetime/tests/test_datetime.py 1.3 => 1.4 ===
--- Zope3/lib/python/datetime/tests/test_datetime.py:1.3	Sat Dec 21 00:10:43 2002
+++ Zope3/lib/python/datetime/tests/test_datetime.py	Sat Dec 21 12:42:02 2002
@@ -1569,6 +1569,12 @@
         self.assertEqual(t1.strftime("%H:%M %%Z='%Z' %%z='%z'"),
                                      "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):
         # Offsets that overflow a basic time.