From 7cbd25a06e820cbd1a0bfbc339fb7d9a737c54fa Mon Sep 17 00:00:00 2001 From: Ad Timmering Date: Mon, 30 Sep 2019 14:35:59 +0200 Subject: [PATCH] Refs #28690 -- Added more tests for parse_http_date(). --- tests/utils_tests/test_http.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/tests/utils_tests/test_http.py b/tests/utils_tests/test_http.py index bc8bcfe977..f8017ae1cb 100644 --- a/tests/utils_tests/test_http.py +++ b/tests/utils_tests/test_http.py @@ -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')