]> granicus.if.org Git - python/commitdiff
Added test to ensure that non-string result from dst() raises TypeError.
authorTim Peters <tim.peters@gmail.com>
Sat, 21 Dec 2002 17:44:07 +0000 (17:44 +0000)
committerTim Peters <tim.peters@gmail.com>
Sat, 21 Dec 2002 17:44:07 +0000 (17:44 +0000)
Lib/test/test_datetime.py

index 9f8ea1de7db9d31251410121e549b2a2df45ac4c..9fd38f14bc7cfc807b338b542fadb2127959fb1d 100644 (file)
@@ -1561,6 +1561,12 @@ class TestTimeTZ(TestTime):
         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.