diff --git a/Lib/rfc822.py b/Lib/rfc822.py index aa58f1889ef7..826269fe1a15 100644 --- a/Lib/rfc822.py +++ b/Lib/rfc822.py @@ -352,7 +352,7 @@ def getaddrlist(self, name): raw.append(addr) alladdrs = ''.join(raw) a = AddressList(alladdrs) - return a.getaddrlist() + return a.addresslist def getdate(self, name): """Retrieve a date field from a header. diff --git a/Lib/test/test_rfc822.py b/Lib/test/test_rfc822.py index 0244f0d81835..dfce7c915121 100644 --- a/Lib/test/test_rfc822.py +++ b/Lib/test/test_rfc822.py @@ -185,7 +185,7 @@ def test_rfc2822_phrases(self): self.check('To: User J. Person \n\n', [('User J. Person', 'person@dom.ain')]) - # This takes to long to add to the test suite + # This takes too long to add to the test suite ## def test_an_excrutiatingly_long_address_field(self): ## OBSCENELY_LONG_HEADER_MULTIPLIER = 10000 ## oneaddr = ('Person' * 10) + '@' + ('.'.join(['dom']*10)) + '.com' @@ -193,6 +193,25 @@ def test_rfc2822_phrases(self): ## lst = rfc822.AddrlistClass(addr).getaddrlist() ## self.assertEqual(len(lst), OBSCENELY_LONG_HEADER_MULTIPLIER) + def test_2getaddrlist(self): + eq = self.assertEqual + msg = self.create_message("""\ +To: aperson@dom.ain +Cc: bperson@dom.ain +Cc: cperson@dom.ain +Cc: dperson@dom.ain + +A test message. +""") + ccs = [('', a) for a in + ['bperson@dom.ain', 'cperson@dom.ain', 'dperson@dom.ain']] + addrs = msg.getaddrlist('cc') + addrs.sort() + eq(addrs, ccs) + # Try again, this one used to fail + addrs = msg.getaddrlist('cc') + addrs.sort() + eq(addrs, ccs) def test_main(): test_support.run_unittest(MessageTestCase)