[Python-checkins] CVS: python/dist/src/Lib/test test_email.py,1.8,1.9

Barry Warsaw bwarsaw@users.sourceforge.net
Thu, 11 Oct 2001 08:44:54 -0700


Update of /cvsroot/python/python/dist/src/Lib/test
In directory usw-pr-cvs1:/tmp/cvs-serv28459

Modified Files:
	test_email.py 
Log Message:
Add a test for the HeaderParser class.


Index: test_email.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_email.py,v
retrieving revision 1.8
retrieving revision 1.9
diff -C2 -d -r1.8 -r1.9
*** test_email.py	2001/10/09 19:23:57	1.8
--- test_email.py	2001/10/11 15:44:50	1.9
***************
*** 11,15 ****
  import email
  
! from email.Parser import Parser
  from email.Generator import Generator, DecodedGenerator
  from email.Message import Message
--- 11,15 ----
  import email
  
! from email.Parser import Parser, HeaderParser
  from email.Generator import Generator, DecodedGenerator
  from email.Message import Message
***************
*** 889,892 ****
--- 889,907 ----
  
  
+ 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()
***************
*** 905,908 ****
--- 920,924 ----
      suite.addTest(unittest.makeSuite(TestMiscellaneous))
      suite.addTest(unittest.makeSuite(TestIterators))
+     suite.addTest(unittest.makeSuite(TestParsers))
      return suite