summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_datetime.py
diff options
context:
space:
mode:
authorTim Peters <tim.peters@gmail.com>2002-12-21 17:44:07 (GMT)
committerTim Peters <tim.peters@gmail.com>2002-12-21 17:44:07 (GMT)
commitb92bb71be8e9deb6feb1bf1c4230562d34ffd4b9 (patch)
tree6439c84aa025a7bfd1bff3fbb30514ffd33bc165 /Lib/test/test_datetime.py
parentfb8472c79c1c858785b8d282f4fc62357c19c244 (diff)
downloadcpython-b92bb71be8e9deb6feb1bf1c4230562d34ffd4b9.zip
cpython-b92bb71be8e9deb6feb1bf1c4230562d34ffd4b9.tar.gz
cpython-b92bb71be8e9deb6feb1bf1c4230562d34ffd4b9.tar.bz2
Added test to ensure that non-string result from dst() raises TypeError.
Diffstat (limited to 'Lib/test/test_datetime.py')
-rw-r--r--Lib/test/test_datetime.py6
1 files changed, 6 insertions, 0 deletions
diff --git a/Lib/test/test_datetime.py b/Lib/test/test_datetime.py
index 9f8ea1d..9fd38f1 100644
--- a/Lib/test/test_datetime.py
+++ b/Lib/test/test_datetime.py
@@ -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.