diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2016-03-12 08:51:16 (GMT) |
---|---|---|
committer | Serhiy Storchaka <storchaka@gmail.com> | 2016-03-12 08:51:16 (GMT) |
commit | 8a7240eeed609f747bdf38985679816ed9f61a0e (patch) | |
tree | 792f7cecbe5cd15b29433d8f7acb3023f89325ef /Lib/test/test_strptime.py | |
parent | d7569637b53d457423d47e83bd9ec35ce1aba772 (diff) | |
download | cpython-8a7240eeed609f747bdf38985679816ed9f61a0e.zip cpython-8a7240eeed609f747bdf38985679816ed9f61a0e.tar.gz cpython-8a7240eeed609f747bdf38985679816ed9f61a0e.tar.bz2 |
Issue #23718: Fixed parsing time in week 0 before Jan 1. Original patch by
Tamás Bence Gedai.
Diffstat (limited to 'Lib/test/test_strptime.py')
-rw-r--r-- | Lib/test/test_strptime.py | 28 |
1 files changed, 21 insertions, 7 deletions
diff --git a/Lib/test/test_strptime.py b/Lib/test/test_strptime.py index 0319d5d..85126e6 100644 --- a/Lib/test/test_strptime.py +++ b/Lib/test/test_strptime.py @@ -496,14 +496,14 @@ class CalculationTests(unittest.TestCase): 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 %U %w', 2014, 12, 28, 0, 0, 0, 6, 362) 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 1', '%Y %U %w', 2014, 12, 29, 0, 0, 0, 0, 363) + check('2015 0 1', '%Y %W %w', 2014, 12, 29, 0, 0, 0, 0, 363) + check('2015 0 2', '%Y %U %w', 2014, 12, 30, 0, 0, 0, 1, 364) + check('2015 0 2', '%Y %W %w', 2014, 12, 30, 0, 0, 0, 1, 364) + check('2015 0 3', '%Y %U %w', 2014, 12, 31, 0, 0, 0, 2, 365) + check('2015 0 3', '%Y %W %w', 2014, 12, 31, 0, 0, 0, 2, 365) 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) @@ -511,6 +511,20 @@ class CalculationTests(unittest.TestCase): 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) + check('2009 0 0', '%Y %U %w', 2008, 12, 28, 0, 0, 0, 6, 363) + check('2009 0 0', '%Y %W %w', 2009, 1, 4, 0, 0, 0, 6, 4) + check('2009 0 1', '%Y %U %w', 2008, 12, 29, 0, 0, 0, 0, 364) + check('2009 0 1', '%Y %W %w', 2008, 12, 29, 0, 0, 0, 0, 364) + check('2009 0 2', '%Y %U %w', 2008, 12, 30, 0, 0, 0, 1, 365) + check('2009 0 2', '%Y %W %w', 2008, 12, 30, 0, 0, 0, 1, 365) + check('2009 0 3', '%Y %U %w', 2008, 12, 31, 0, 0, 0, 2, 366) + check('2009 0 3', '%Y %W %w', 2008, 12, 31, 0, 0, 0, 2, 366) + check('2009 0 4', '%Y %U %w', 2009, 1, 1, 0, 0, 0, 3, 1) + check('2009 0 4', '%Y %W %w', 2009, 1, 1, 0, 0, 0, 3, 1) + check('2009 0 5', '%Y %U %w', 2009, 1, 2, 0, 0, 0, 4, 2) + check('2009 0 5', '%Y %W %w', 2009, 1, 2, 0, 0, 0, 4, 2) + check('2009 0 6', '%Y %U %w', 2009, 1, 3, 0, 0, 0, 5, 3) + check('2009 0 6', '%Y %W %w', 2009, 1, 3, 0, 0, 0, 5, 3) class CacheTests(unittest.TestCase): """Test that caching works properly.""" |