[Python-checkins] python/dist/src/Lib/test test_email.py,1.39,1.40

bwarsaw@users.sourceforge.net bwarsaw@users.sourceforge.net
Tue, 09 Jul 2002 09:36:40 -0700


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

Modified Files:
	test_email.py 
Log Message:
ndiffAssertEqual(): Stringify the arguments before running
.splitlines() on them, since they may be Header instances.

test_multilingual(), test_header_ctor_default_args(): New tests of
make_header() and that Header can take all default arguments.


Index: test_email.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_email.py,v
retrieving revision 1.39
retrieving revision 1.40
diff -C2 -d -r1.39 -r1.40
*** test_email.py	9 Jul 2002 02:38:24 -0000	1.39
--- test_email.py	9 Jul 2002 16:36:36 -0000	1.40
***************
*** 15,19 ****
  
  from email.Charset import Charset
! from email.Header import Header, decode_header
  from email.Parser import Parser, HeaderParser
  from email.Generator import Generator, DecodedGenerator
--- 15,19 ----
  
  from email.Charset import Charset
! from email.Header import Header, decode_header, make_header
  from email.Parser import Parser, HeaderParser
  from email.Generator import Generator, DecodedGenerator
***************
*** 58,62 ****
              """Like failUnlessEqual except use ndiff for readable output."""
              if first <> second:
!                 diff = difflib.ndiff(first.splitlines(), second.splitlines())
                  fp = StringIO()
                  print >> fp, NL, NL.join(diff)
--- 58,64 ----
              """Like failUnlessEqual except use ndiff for readable output."""
              if first <> second:
!                 sfirst = str(first)
!                 ssecond = str(second)
!                 diff = difflib.ndiff(sfirst.splitlines(), ssecond.splitlines())
                  fp = StringIO()
                  print >> fp, NL, NL.join(diff)
***************
*** 1027,1031 ****
          eq = self.assertEqual
          unless = self.failUnless
!         # msg 16 is a Delivery Status Notification, see RFC XXXX
          msg = self._msgobj('msg_16.txt')
          eq(msg.get_type(), 'multipart/report')
--- 1029,1033 ----
          eq = self.assertEqual
          unless = self.failUnless
!         # msg 16 is a Delivery Status Notification, see RFC 1894
          msg = self._msgobj('msg_16.txt')
          eq(msg.get_type(), 'multipart/report')
***************
*** 1879,1883 ****
  
      def test_multilingual(self):
!         eq = self.assertEqual
          g = Charset("iso-8859-1")
          cz = Charset("iso-8859-2")
--- 1881,1885 ----
  
      def test_multilingual(self):
!         eq = self.ndiffAssertEqual
          g = Charset("iso-8859-1")
          cz = Charset("iso-8859-2")
***************
*** 1930,1933 ****
--- 1932,1945 ----
             'gersput.\xe3\x80\x8d\xe3\x81\xa8\xe8\xa8\x80\xe3\x81\xa3\xe3\x81'
             '\xa6\xe3\x81\x84\xe3\x81\xbe\xe3\x81\x99\xe3\x80\x82')
+         # Test make_header()
+         newh = make_header(decode_header(enc))
+         eq(newh, enc)
+ 
+     def test_header_ctor_default_args(self):
+         eq = self.ndiffAssertEqual
+         h = Header()
+         eq(h, '')
+         h.append('foo', Charset('iso-8859-1'))
+         eq(h, '=?iso-8859-1?q?foo?=')
  
      def test_explicit_maxlinelen(self):