[Python-checkins] python/dist/src/Lib/test test_strptime.py,1.5,1.6

barry@users.sourceforge.net barry@users.sourceforge.net
Mon, 23 Sep 2002 15:46:53 -0700


Update of /cvsroot/python/python/dist/src/Lib/test
In directory usw-pr-cvs1:/tmp/cvs-serv4741

Modified Files:
	test_strptime.py 
Log Message:
Brett's fixes for various bugs and coding issues.  Closes SF patch #
593560, with some minor cleanups, line folding and whitespace
normalization by Barry.


Index: test_strptime.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_strptime.py,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** test_strptime.py	3 Sep 2002 21:10:10 -0000	1.5
--- test_strptime.py	23 Sep 2002 22:46:49 -0000	1.6
***************
*** 1,3 ****
! """PyUnit testing against strptime >= 2.1.0."""
  
  import unittest
--- 1,3 ----
! """PyUnit testing against strptime"""
  
  import unittest
***************
*** 56,65 ****
      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")
  
      def test_lang(self):
--- 56,74 ----
      def test_date_time(self):
          # Check that LC_date_time, LC_date, and LC_time are correct
!         # 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):
***************
*** 221,224 ****
--- 230,243 ----
          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):