summaryrefslogtreecommitdiffstats
path: root/Lib/test
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2016-03-12 08:53:09 (GMT)
committerSerhiy Storchaka <storchaka@gmail.com>2016-03-12 08:53:09 (GMT)
commit6e4150f36b74622a23ea0fd259bd61bbd753d3fd (patch)
tree84db1e42e46f64a4339bd85c3500c7424effd112 /Lib/test
parent15a83e845fa2421428f9d06c6fe6e85fde59d22c (diff)
parent8a7240eeed609f747bdf38985679816ed9f61a0e (diff)
downloadcpython-6e4150f36b74622a23ea0fd259bd61bbd753d3fd.zip
cpython-6e4150f36b74622a23ea0fd259bd61bbd753d3fd.tar.gz
cpython-6e4150f36b74622a23ea0fd259bd61bbd753d3fd.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')
-rw-r--r--Lib/test/test_strptime.py36
1 files changed, 29 insertions, 7 deletions
diff --git a/Lib/test/test_strptime.py b/Lib/test/test_strptime.py
index 2a1f059..1cc8b42 100644
--- a/Lib/test/test_strptime.py
+++ b/Lib/test/test_strptime.py
@@ -520,17 +520,17 @@ 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 1 1', '%G %V %u', 2014, 12, 29, 0, 0, 0, 0, 363)
- 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 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 1 2', '%G %V %u', 2014, 12, 30, 0, 0, 0, 1, 364)
- 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 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 1 3', '%G %V %u', 2014, 12, 31, 0, 0, 0, 2, 365)
- 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 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 1 4', '%G %V %u', 2015, 1, 1, 0, 0, 0, 3, 1)
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)
@@ -542,6 +542,28 @@ class CalculationTests(unittest.TestCase):
check('2015 0 6', '%Y %W %w', 2015, 1, 3, 0, 0, 0, 5, 3)
check('2015 1 7', '%G %V %u', 2015, 1, 4, 0, 0, 0, 6, 4)
+ 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 1 1', '%G %V %u', 2008, 12, 29, 0, 0, 0, 0, 364)
+ 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 1 2', '%G %V %u', 2008, 12, 30, 0, 0, 0, 1, 365)
+ 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 1 3', '%G %V %u', 2008, 12, 31, 0, 0, 0, 2, 366)
+ 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 1 4', '%G %V %u', 2009, 1, 1, 0, 0, 0, 3, 1)
+ 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 1 5', '%G %V %u', 2009, 1, 2, 0, 0, 0, 4, 2)
+ 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 1 6', '%G %V %u', 2009, 1, 3, 0, 0, 0, 5, 3)
+ 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)
+ check('2009 1 7', '%G %V %u', 2009, 1, 4, 0, 0, 0, 6, 4)
+
class CacheTests(unittest.TestCase):
"""Test that caching works properly."""