Fix handling of bad locale setup where time.tzname[0] == time.tzname[1] and
time.daylight is true. Add an explicit test for this situation.
Fixed some wording in docstrings.
diff --git a/Lib/test/test_strptime.py b/Lib/test/test_strptime.py
index fef5d90..4ce37f8 100644
--- a/Lib/test/test_strptime.py
+++ b/Lib/test/test_strptime.py
@@ -5,6 +5,7 @@
import locale
import re
import sets
+import sys
from test import test_support
import _strptime
@@ -258,6 +259,9 @@
self.failUnlessEqual(strp_output.tm_isdst, 0)
strp_output = _strptime.strptime("GMT", "%Z")
self.failUnlessEqual(strp_output.tm_isdst, 0)
+ if sys.platform == "mac":
+ # Timezones don't really work on MacOS9
+ return
time_tuple = time.localtime()
strf_output = time.strftime("%Z") #UTC does not have a timezone
strp_output = _strptime.strptime(strf_output, "%Z")
@@ -271,6 +275,22 @@
"LocaleTime().timezone has duplicate values and "
"time.daylight but timezone value not set to -1")
+ def test_bad_timezone(self):
+ # Explicitly test possibility of bad timezone;
+ # when time.tzname[0] == time.tzname[1] and time.daylight
+ if sys.platform == "mac":
+ return #MacOS9 has severely broken timezone support.
+ try:
+ original_tzname = time.tzname
+ original_daylight = time.daylight
+ time.tzname = ("PDT", "PDT")
+ time.daylight = 1
+ tz_value = _strptime.strptime("PDT", "%Z")[8]
+ self.failUnlessEqual(tz_value, -1)
+ finally:
+ time.tzname = original_tzname
+ time.daylight = original_daylight
+
def test_date_time(self):
# Test %c directive
for position in range(6):