diff options
author | Barry Warsaw <barry@python.org> | 2001-10-11 15:44:50 (GMT) |
---|---|---|
committer | Barry Warsaw <barry@python.org> | 2001-10-11 15:44:50 (GMT) |
commit | bf7a59d94b5efd1e675b8365a686b48f2b260736 (patch) | |
tree | 5212d3af6b1794d6b038ea5be17b9156f5eb6bbe /Lib | |
parent | e552882960e4caa26ec80465ee501da17bc29e51 (diff) | |
download | cpython-bf7a59d94b5efd1e675b8365a686b48f2b260736.zip cpython-bf7a59d94b5efd1e675b8365a686b48f2b260736.tar.gz cpython-bf7a59d94b5efd1e675b8365a686b48f2b260736.tar.bz2 |
Add a test for the HeaderParser class.
Diffstat (limited to 'Lib')
-rw-r--r-- | Lib/test/test_email.py | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/Lib/test/test_email.py b/Lib/test/test_email.py index e5ddebb..3134a88 100644 --- a/Lib/test/test_email.py +++ b/Lib/test/test_email.py @@ -10,7 +10,7 @@ from types import StringType import email -from email.Parser import Parser +from email.Parser import Parser, HeaderParser from email.Generator import Generator, DecodedGenerator from email.Message import Message from email.MIMEAudio import MIMEAudio @@ -888,6 +888,21 @@ to reflect upon our own +class TestParsers(unittest.TestCase): + def test_header_parser(self): + eq = self.assertEqual + # Parse only the headers of a complex multipart MIME document + p = HeaderParser() + fp = openfile('msg_02.txt') + msg = p.parse(fp) + eq(msg['from'], 'ppp-request@zzz.org') + eq(msg['to'], 'ppp@zzz.org') + eq(msg.get_type(), 'multipart/mixed') + eq(msg.is_multipart(), 0) + self.failUnless(isinstance(msg.get_payload(), StringType)) + + + def suite(): suite = unittest.TestSuite() suite.addTest(unittest.makeSuite(TestMessageAPI)) @@ -904,6 +919,7 @@ def suite(): suite.addTest(unittest.makeSuite(TestIdempotent)) suite.addTest(unittest.makeSuite(TestMiscellaneous)) suite.addTest(unittest.makeSuite(TestIterators)) + suite.addTest(unittest.makeSuite(TestParsers)) return suite |