diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2015-03-19 17:14:15 (GMT) |
---|---|---|
committer | Serhiy Storchaka <storchaka@gmail.com> | 2015-03-19 17:14:15 (GMT) |
commit | fc7344a79219643a18449074c09d28773a70f975 (patch) | |
tree | e383b68225b76876bbf9a566fc1db8ce4dbb6041 /Lib/test | |
parent | 4f418d36714787fa85652806c93405e4874bca61 (diff) | |
parent | 423feea01e40699ad4e4c91139a64c71578b4eef (diff) | |
download | cpython-fc7344a79219643a18449074c09d28773a70f975.zip cpython-fc7344a79219643a18449074c09d28773a70f975.tar.gz cpython-fc7344a79219643a18449074c09d28773a70f975.tar.bz2 |
Issue #23136: _strptime now uniformly handles all days in week 0, including
Jan 30 of previous year. Based on patch by Jim Carroll.
Diffstat (limited to 'Lib/test')
-rw-r--r-- | Lib/test/test_strptime.py | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/Lib/test/test_strptime.py b/Lib/test/test_strptime.py index 13a72d4..2a6f3f8 100644 --- a/Lib/test/test_strptime.py +++ b/Lib/test/test_strptime.py @@ -494,6 +494,24 @@ class CalculationTests(unittest.TestCase): test_helper((2006, 12, 31), "Last Sunday of 2006") test_helper((2006, 12, 24), "Second to last Sunday of 2006") + def test_week_0(self): + def check(value, format, *expected): + self.assertEqual(_strptime._strptime_time(value, format)[:-1], expected) + check('2015 0 0', '%Y %U %w', 2014, 12, 28, 0, 0, 0, 6, -3) + check('2015 0 0', '%Y %W %w', 2015, 1, 4, 0, 0, 0, 6, 4) + check('2015 0 1', '%Y %U %w', 2014, 12, 29, 0, 0, 0, 0, -2) + check('2015 0 1', '%Y %W %w', 2014, 12, 29, 0, 0, 0, 0, -2) + check('2015 0 2', '%Y %U %w', 2014, 12, 30, 0, 0, 0, 1, -1) + check('2015 0 2', '%Y %W %w', 2014, 12, 30, 0, 0, 0, 1, -1) + check('2015 0 3', '%Y %U %w', 2014, 12, 31, 0, 0, 0, 2, 0) + check('2015 0 3', '%Y %W %w', 2014, 12, 31, 0, 0, 0, 2, 0) + check('2015 0 4', '%Y %U %w', 2015, 1, 1, 0, 0, 0, 3, 1) + check('2015 0 4', '%Y %W %w', 2015, 1, 1, 0, 0, 0, 3, 1) + check('2015 0 5', '%Y %U %w', 2015, 1, 2, 0, 0, 0, 4, 2) + check('2015 0 5', '%Y %W %w', 2015, 1, 2, 0, 0, 0, 4, 2) + check('2015 0 6', '%Y %U %w', 2015, 1, 3, 0, 0, 0, 5, 3) + check('2015 0 6', '%Y %W %w', 2015, 1, 3, 0, 0, 0, 5, 3) + class CacheTests(unittest.TestCase): """Test that caching works properly.""" |