summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_strptime.py
diff options
context:
space:
mode:
authorBrett Cannon <bcannon@gmail.com>2003-05-11 06:23:36 (GMT)
committerBrett Cannon <bcannon@gmail.com>2003-05-11 06:23:36 (GMT)
commit172d9ef47eafe6982c2c885353af761256e7b409 (patch)
tree145629dd55cb43474872592c82194da5cc6e16ed /Lib/test/test_strptime.py
parentc2409b4f5a9158bd11999c5c210c7533e576dc42 (diff)
downloadcpython-172d9ef47eafe6982c2c885353af761256e7b409.zip
cpython-172d9ef47eafe6982c2c885353af761256e7b409.tar.gz
cpython-172d9ef47eafe6982c2c885353af761256e7b409.tar.bz2
Beefed up timezone support. UTC and GMT are now always recognized timezones
with values of 0. Also now check time.daylight to see if time.tzname[1] should be used in timezone checking.
Diffstat (limited to 'Lib/test/test_strptime.py')
-rw-r--r--Lib/test/test_strptime.py19
1 files changed, 14 insertions, 5 deletions
diff --git a/Lib/test/test_strptime.py b/Lib/test/test_strptime.py
index 140b226..c9d705b 100644
--- a/Lib/test/test_strptime.py
+++ b/Lib/test/test_strptime.py
@@ -58,9 +58,11 @@ class LocaleTime_Tests(unittest.TestCase):
def test_timezone(self):
# Make sure timezone is correct
- if time.strftime("%Z", self.time_tuple):
- self.compare_against_time(self.LT_ins.timezone, '%Z', 8,
- "Testing against timezone failed")
+ timezone = time.strftime("%Z", self.time_tuple)
+ if timezone:
+ self.failUnless(timezone in self.LT_ins.timezone,
+ "timezone %s not found in %s" %
+ (timezone, self.LT_ins.timezone))
def test_date_time(self):
# Check that LC_date_time, LC_date, and LC_time are correct
@@ -293,18 +295,25 @@ class StrptimeTests(unittest.TestCase):
# When gmtime() is used with %Z, entire result of strftime() is empty.
# Check for equal timezone names deals with bad locale info when this
# occurs; first found in FreeBSD 4.4.
+ strp_output = _strptime.strptime("UTC", "%Z")
+ self.failUnlessEqual(strp_output.tm_isdst, 0)
+ strp_output = _strptime.strptime("GMT", "%Z")
+ self.failUnlessEqual(strp_output.tm_isdst, 0)
+ if time.daylight:
+ strp_output = _strptime.strptime(time.tzname[1], "%Z")
+ self.failUnlessEqual(strp_output[8], 1)
time_tuple = time.localtime()
strf_output = time.strftime("%Z") #UTC does not have a timezone
strp_output = _strptime.strptime(strf_output, "%Z")
locale_time = _strptime.LocaleTime()
- if locale_time.timezone[0] != locale_time.timezone[1]:
+ if time.tzname[0] != time.tzname[1]:
self.failUnless(strp_output[8] == time_tuple[8],
"timezone check failed; '%s' -> %s != %s" %
(strf_output, strp_output[8], time_tuple[8]))
else:
self.failUnless(strp_output[8] == -1,
"LocaleTime().timezone has duplicate values but "
- "timzone value not set to 0")
+ "timzone value not set to -1")
def test_date_time(self):
# Test %c directive