1 from test_support
import verbose
4 from cStringIO
import StringIO
6 from StringIO
import StringIO
8 def test(msg
, results
):
12 m
= rfc822
.Message(fp
)
14 for n
, a
in m
.getaddrlist('to') + m
.getaddrlist('cc'):
16 print 'name:', repr(n
), 'addr:', repr(a
)
18 mn
, ma
= results
[i
][0], results
[i
][1]
20 print 'extra parsed address:', repr(n
), repr(a
)
23 if mn
== n
and ma
== a
:
29 print 'not found:', repr(n
), repr(a
)
31 test('''Date: Wed, 13 Jan 1999 23:57:35 -0500
32 From: Guido van Rossum <guido@CNRI.Reston.VA.US>
34 : Rossum" <guido@python.org>
38 ''', [('Guido van\n : Rossum', 'guido@python.org')])
40 test('''From: Barry <bwarsaw@python.org
41 To: guido@python.org (Guido: the Barbarian)
44 test''', [('Guido: the Barbarian', 'guido@python.org'),
47 test('''From: Barry <bwarsaw@python.org
48 To: guido@python.org (Guido: the Barbarian)
49 Cc: "Guido: the Madman" <guido@python.org>
51 test''', [('Guido: the Barbarian', 'guido@python.org'),
52 ('Guido: the Madman', 'guido@python.org')
55 test('''To: "The monster with
56 the very long name: Guido" <guido@python.org>
58 test''', [('The monster with\n the very long name: Guido',
61 test('''To: "Amit J. Patel" <amitp@Theory.Stanford.EDU>
62 CC: Mike Fletcher <mfletch@vrtelecom.com>,
63 "'string-sig@python.org'" <string-sig@python.org>
64 Cc: fooz@bat.com, bart@toof.com
67 test''', [('Amit J. Patel', 'amitp@Theory.Stanford.EDU'),
68 ('Mike Fletcher', 'mfletch@vrtelecom.com'),
69 ("'string-sig@python.org'", 'string-sig@python.org'),
71 ('', 'bart@toof.com'),
75 # This one is just twisted. I don't know what the proper result should be,
76 # but it shouldn't be to infloop, which is what used to happen!
77 test('''To: <[smtp:dd47@mail.xxx.edu]_at_hmhq@hdq-mdm1-imgout.companay.com>
80 ('', 'dd47@mail.xxx.edu'),
81 ('', '_at_hmhq@hdq-mdm1-imgout.companay.com')