summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_email
diff options
context:
space:
mode:
authorGeorg Brandl <georg@python.org>2012-09-22 07:03:56 (GMT)
committerGeorg Brandl <georg@python.org>2012-09-22 07:03:56 (GMT)
commit1aca31e8f329e19de62a2f1a2080995e5712a9cd (patch)
tree9a3d62178053892e1bb1033032f88977746a7951 /Lib/test/test_email
parentdeb92b5b1b015191bb9f072b67536e471bd37a7a (diff)
downloadcpython-1aca31e8f329e19de62a2f1a2080995e5712a9cd.zip
cpython-1aca31e8f329e19de62a2f1a2080995e5712a9cd.tar.gz
cpython-1aca31e8f329e19de62a2f1a2080995e5712a9cd.tar.bz2
Closes #15925: fix regression in parsedate() and parsedate_tz() that should return None if unable to parse the argument.
Diffstat (limited to 'Lib/test/test_email')
-rw-r--r--Lib/test/test_email/test_email.py13
1 files changed, 11 insertions, 2 deletions
diff --git a/Lib/test/test_email/test_email.py b/Lib/test/test_email/test_email.py
index 5cc6d04..36c344f 100644
--- a/Lib/test/test_email/test_email.py
+++ b/Lib/test/test_email/test_email.py
@@ -2718,8 +2718,17 @@ class TestMiscellaneous(TestEmailBase):
utils.formatdate(now, localtime=False, usegmt=True),
time.strftime('%a, %d %b %Y %H:%M:%S GMT', time.gmtime(now)))
- def test_parsedate_none(self):
- self.assertEqual(utils.parsedate(''), None)
+ # parsedate and parsedate_tz will become deprecated interfaces someday
+ def test_parsedate_returns_None_for_invalid_strings(self):
+ self.assertIsNone(utils.parsedate(''))
+ self.assertIsNone(utils.parsedate_tz(''))
+ self.assertIsNone(utils.parsedate('0'))
+ self.assertIsNone(utils.parsedate_tz('0'))
+ self.assertIsNone(utils.parsedate('A Complete Waste of Time'))
+ self.assertIsNone(utils.parsedate_tz('A Complete Waste of Time'))
+ # Not a part of the spec but, but this has historically worked:
+ self.assertIsNone(utils.parsedate(None))
+ self.assertIsNone(utils.parsedate_tz(None))
def test_parsedate_compact(self):
# The FWS after the comma is optional