[Python-checkins] python/dist/src/Lib/test test_strptime.py, 1.27,
1.28
bcannon at users.sourceforge.net
bcannon at users.sourceforge.net
Mon Oct 18 03:37:59 CEST 2004
Update of /cvsroot/python/python/dist/src/Lib/test
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22698/Lib/test
Modified Files:
test_strptime.py
Log Message:
Add support for %U and %W to contribute to calculating the date when the year
and day of the week are specified.
Closes bug #1045381.
Index: test_strptime.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_strptime.py,v
retrieving revision 1.27
retrieving revision 1.28
diff -u -d -r1.27 -r1.28
--- test_strptime.py 6 Oct 2004 02:11:36 -0000 1.27
+++ test_strptime.py 18 Oct 2004 01:37:57 -0000 1.28
@@ -6,6 +6,7 @@
import re
import sys
from test import test_support
+from datetime import date as datetime_date
import _strptime
@@ -417,6 +418,27 @@
"Calculation of day of the week failed;"
"%s != %s" % (result.tm_wday, self.time_tuple.tm_wday))
+ def test_week_of_year_and_day_of_week_calculation(self):
+ # Should be able to infer date if given year, week of year (%U or %W)
+ # and day of the week
+ 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)
+ strp_output = _strptime.strptime(strp_input, format_string)
+ self.failUnless(strp_output[:3] == ymd_tuple,
+ "%s(%s) test failed w/ '%s': %s != %s" %
+ (test_reason, directive, strp_input,
+ strp_output[:3], ymd_tuple[:3]))
+ 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((1905, 12, 31), "Dec 31 on Sunday")
+ test_helper((1906, 12, 31), "Dec 31 on Monday")
+
class CacheTests(unittest.TestCase):
"""Test that caching works properly."""
More information about the Python-checkins
mailing list