Commit f6553284 authored by Barry Warsaw's avatar Barry Warsaw

parseaddr(): Fixed in the same way that Message.getaddrlist() was

fixed (re: SF bug #555035).  Include a unittest.
parent 12424bc0
......@@ -495,7 +495,7 @@ def quote(str):
def parseaddr(address):
"""Parse an address into a (realname, mailaddr) tuple."""
a = AddressList(address)
list = a.getaddrlist()
list = a.addresslist
if not list:
return (None, None)
else:
......
......@@ -213,6 +213,15 @@ A test message.
addrs.sort()
eq(addrs, ccs)
def test_parseaddr(self):
eq = self.assertEqual
eq(rfc822.parseaddr('<>'), ('', ''))
eq(rfc822.parseaddr('aperson@dom.ain'), ('', 'aperson@dom.ain'))
eq(rfc822.parseaddr('bperson@dom.ain (Bea A. Person)'),
('Bea A. Person', 'bperson@dom.ain'))
eq(rfc822.parseaddr('Cynthia Person <cperson@dom.ain>'),
('Cynthia Person', 'cperson@dom.ain'))
def test_main():
test_support.run_unittest(MessageTestCase)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment