[3.0.x] Refs #28690 -- Added more tests for parse_http_date().

Backport of 7cbd25a06e from master
This commit is contained in:
Ad Timmering 2019-09-30 14:35:59 +02:00 committed by Mariusz Felisiak
parent df0c2ac358
commit f38655ed1c
1 changed files with 12 additions and 2 deletions

View File

@ -317,8 +317,18 @@ class HttpDateProcessingTests(unittest.TestCase):
self.assertEqual(datetime.utcfromtimestamp(parsed), datetime(1994, 11, 6, 8, 49, 37))
def test_parsing_rfc850(self):
parsed = parse_http_date('Sunday, 06-Nov-94 08:49:37 GMT')
self.assertEqual(datetime.utcfromtimestamp(parsed), datetime(1994, 11, 6, 8, 49, 37))
tests = (
('Tuesday, 31-Dec-69 08:49:37 GMT', datetime(2069, 12, 31, 8, 49, 37)),
('Tuesday, 10-Nov-70 08:49:37 GMT', datetime(1970, 11, 10, 8, 49, 37)),
('Sunday, 06-Nov-94 08:49:37 GMT', datetime(1994, 11, 6, 8, 49, 37)),
('Friday, 31-Dec-71 08:49:37 GMT', datetime(1971, 12, 31, 8, 49, 37)),
('Sunday, 31-Dec-00 08:49:37 GMT', datetime(2000, 12, 31, 8, 49, 37)),
('Friday, 31-Dec-99 08:49:37 GMT', datetime(1999, 12, 31, 8, 49, 37)),
)
for rfc850str, expected_date in tests:
with self.subTest(rfc850str=rfc850str):
parsed = parse_http_date(rfc850str)
self.assertEqual(datetime.utcfromtimestamp(parsed), expected_date)
def test_parsing_asctime(self):
parsed = parse_http_date('Sun Nov 6 08:49:37 1994')