From bf7a59d94b5efd1e675b8365a686b48f2b260736 Mon Sep 17 00:00:00 2001 From: Barry Warsaw Date: Thu, 11 Oct 2001 15:44:50 +0000 Subject: [PATCH] Add a test for the HeaderParser class. --- Lib/test/test_email.py | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/Lib/test/test_email.py b/Lib/test/test_email.py index e5ddebb3dae..3134a88e013 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 @@ -887,6 +887,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() @@ -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