[Python-checkins] python/dist/src/Lib/test test_strptime.py,
1.19.4.4, 1.19.4.5
bcannon at users.sourceforge.net
bcannon at users.sourceforge.net
Mon Oct 18 03:56:19 CEST 2004
Update of /cvsroot/python/python/dist/src/Lib/test
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27014/Lib/test
Modified Files:
Tag: release23-maint
test_strptime.py
Log Message:
Add support for using %U and %W in strptime when year and day of the week are
also specified.
Closes bug #1045381.
Index: test_strptime.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_strptime.py,v
retrieving revision 1.19.4.4
retrieving revision 1.19.4.5
diff -u -d -r1.19.4.4 -r1.19.4.5
--- test_strptime.py 29 Aug 2003 02:34:22 -0000 1.19.4.4
+++ test_strptime.py 18 Oct 2004 01:56:16 -0000 1.19.4.5
@@ -6,6 +6,7 @@
import re
import sys
from test import test_support
+from datetime import date as datetime_date
import _strptime
@@ -450,6 +451,29 @@
"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