summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_strptime.py
diff options
context:
space:
mode:
authorBarry Warsaw <barry@python.org>2002-09-23 22:46:49 (GMT)
committerBarry Warsaw <barry@python.org>2002-09-23 22:46:49 (GMT)
commit4d895fa1258205e01073f0f9c2aba9a57843ae21 (patch)
treef3e119c4a1615f422b5563f8557cc8761d15790a /Lib/test/test_strptime.py
parent02669a35bc303868f32a24cbcca82917dceea343 (diff)
downloadcpython-4d895fa1258205e01073f0f9c2aba9a57843ae21.zip
cpython-4d895fa1258205e01073f0f9c2aba9a57843ae21.tar.gz
cpython-4d895fa1258205e01073f0f9c2aba9a57843ae21.tar.bz2
Brett's fixes for various bugs and coding issues. Closes SF patch #
593560, with some minor cleanups, line folding and whitespace normalization by Barry.
Diffstat (limited to 'Lib/test/test_strptime.py')
-rw-r--r--Lib/test/test_strptime.py33
1 files changed, 26 insertions, 7 deletions
diff --git a/Lib/test/test_strptime.py b/Lib/test/test_strptime.py
index 4fab085..314f29d 100644
--- a/Lib/test/test_strptime.py
+++ b/Lib/test/test_strptime.py
@@ -1,4 +1,4 @@
-"""PyUnit testing against strptime >= 2.1.0."""
+"""PyUnit testing against strptime"""
import unittest
import time
@@ -55,12 +55,21 @@ class LocaleTime_Tests(unittest.TestCase):
def test_date_time(self):
# Check that LC_date_time, LC_date, and LC_time are correct
-## strftime_output = time.strftime("%c", self.time_tuple)
-## self.failUnless(strftime_output == time.strftime(self.LT_ins.LC_date_time, self.time_tuple), "LC_date_time incorrect")
- strftime_output = time.strftime("%x", self.time_tuple)
- self.failUnless(strftime_output == time.strftime(self.LT_ins.LC_date, self.time_tuple), "LC_date incorrect")
- strftime_output = time.strftime("%X", self.time_tuple)
- self.failUnless(strftime_output == time.strftime(self.LT_ins.LC_time, self.time_tuple), "LC_time incorrect")
+ # the magic date is used so as to not have issues with %c when day of
+ # the month is a single digit and has a leading space. This is not an
+ # issue since strptime still parses it correctly. The problem is
+ # testing these directives for correctness by comparing strftime
+ # output.
+ magic_date = (1999, 3, 17, 22, 44, 55, 2, 76, 0)
+ strftime_output = time.strftime("%c", magic_date)
+ self.failUnless(strftime_output == time.strftime(self.LT_ins.LC_date_time, magic_date), "LC_date_time incorrect")
+ strftime_output = time.strftime("%x", magic_date)
+ self.failUnless(strftime_output == time.strftime(self.LT_ins.LC_date, magic_date), "LC_date incorrect")
+ strftime_output = time.strftime("%X", magic_date)
+ self.failUnless(strftime_output == time.strftime(self.LT_ins.LC_time, magic_date), "LC_time incorrect")
+ LT = _strptime.LocaleTime(am_pm=('',''))
+ self.failUnless(LT.LC_time, "LocaleTime's LC directives cannot handle "
+ "empty strings")
def test_lang(self):
# Make sure lang is set
@@ -221,6 +230,16 @@ class StrptimeTests(unittest.TestCase):
strp_output = _strptime.strptime(strf_output, "%m %% %Y")
self.failUnless(strp_output[0] == self.time_tuple[0] and strp_output[1] == self.time_tuple[1], "handling of percent sign failed")
+ def test_caseinsensitive(self):
+ # Should handle names case-insensitively.
+ strf_output = time.strftime("%B", self.time_tuple)
+ self.failUnless(_strptime.strptime(strf_output.upper(), "%B"),
+ "strptime does not handle ALL-CAPS names properly")
+ self.failUnless(_strptime.strptime(strf_output.lower(), "%B"),
+ "strptime does not handle lowercase names properly")
+ self.failUnless(_strptime.strptime(strf_output.capitalize(), "%B"),
+ "strptime does not handle capword names properly")
+
class FxnTests(unittest.TestCase):
"""Test functions that fill in info by validating result and are triggered properly."""