[Python-checkins] python/dist/src/Lib/test test_strptime.py, 1.19.4.5, 1.19.4.6

bcannon at users.sourceforge.net bcannon at users.sourceforge.net
Thu Oct 28 06:50:30 CEST 2004


Update of /cvsroot/python/python/dist/src/Lib/test
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv32106/Lib/test

Modified Files:
      Tag: release23-maint
	test_strptime.py 
Log Message:
Backport of fix for bug of year/<week of year>/<day of week> calculation that
didn't handle %U for years starting on Monday.


Index: test_strptime.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_strptime.py,v
retrieving revision 1.19.4.5
retrieving revision 1.19.4.6
diff -u -d -r1.19.4.5 -r1.19.4.6
--- test_strptime.py	18 Oct 2004 01:56:16 -0000	1.19.4.5
+++ test_strptime.py	28 Oct 2004 04:50:28 -0000	1.19.4.6
@@ -457,21 +457,35 @@
         def test_helper(ymd_tuple, test_reason):
             for directive in ('W', 'U'):
                 format_string = "%%Y %%%s %%w" % directive
-                strp_input = datetime_date(*ymd_tuple).strftime(format_string)
+                dt_date = datetime_date(*ymd_tuple)
+                strp_input = dt_date.strftime(format_string)
                 strp_output = _strptime.strptime(strp_input, format_string)
                 self.failUnless(strp_output[:3] == ymd_tuple,
-                        "%s(%s) test failed w/ '%s': %s != %s" %
+                        "%s(%s) test failed w/ '%s': %s != %s (%s != %s)" %
                             (test_reason, directive, strp_input,
-                                strp_output[:3], ymd_tuple[:3]))
+                                strp_output[:3], ymd_tuple,
+                                strp_output[7], dt_date.timetuple()[7]))
         test_helper((1901, 1, 3), "week 0")
         test_helper((1901, 1, 8), "common case")
         test_helper((1901, 1, 13), "day on Sunday")
         test_helper((1901, 1, 14), "day on Monday")
         test_helper((1905, 1, 1), "Jan 1 on Sunday")
         test_helper((1906, 1, 1), "Jan 1 on Monday")
+        test_helper((1906, 1, 7), "first Sunday in a year starting on Monday")
         test_helper((1905, 12, 31), "Dec 31 on Sunday")
         test_helper((1906, 12, 31), "Dec 31 on Monday")
-
+        test_helper((2008, 12, 29), "Monday in the last week of the year")
+        test_helper((2008, 12, 22), "Monday in the second-to-last week of the "
+                                    "year")
+        test_helper((1978, 10, 23), "randomly chosen date")
+        test_helper((2004, 12, 18), "randomly chosen date")
+        test_helper((1978, 10, 23), "year starting and ending on Monday while "
+                                        "date not on Sunday or Monday")
+        test_helper((1917, 12, 17), "year starting and ending on Monday with "
+                                        "a Monday not at the beginning or end "
+                                        "of the year")
+        test_helper((1917, 12, 31), "Dec 31 on Monday with year starting and "
+                                        "ending on Monday")
 
 
 class CacheTests(unittest.TestCase):



More information about the Python-checkins mailing list