[Python-checkins] python/dist/src/Lib/test test_mailbox.py, 1.9, 1.10

montanaro at users.sourceforge.net montanaro at users.sourceforge.net
Sat Jul 24 21:56:06 CEST 2004


Update of /cvsroot/python/python/dist/src/Lib/test
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16121
Modified Files:
	test_mailbox.py 
Log Message:
added test for bug #996359.
Index: test_mailbox.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_mailbox.py,v
retrieving revision 1.9
retrieving revision 1.10
diff -C2 -d -r1.9 -r1.10
*** test_mailbox.py	23 Jul 2002 19:03:56 -0000	1.9
--- test_mailbox.py	24 Jul 2004 19:56:03 -0000	1.10
***************
*** 11,23 ****
 pass
 
! 
 DUMMY_MESSAGE = """\
 From: some.body at dummy.domain
 To: me at my.domain
 
 This is a dummy message.
 """
 
- 
 class MaildirTestCase(unittest.TestCase):
 
--- 11,23 ----
 pass
 
! FROM_ = "From some.body at dummy.domain Sat Jul 24 13:43:35 2004\n"
 DUMMY_MESSAGE = """\
 From: some.body at dummy.domain
 To: me at my.domain
+ Subject: Simple Test
 
 This is a dummy message.
 """
 
 class MaildirTestCase(unittest.TestCase):
 
***************
*** 39,43 ****
 os.rmdir(self._dir)
 
! def createMessage(self, dir):
 t = int(time.time() % 1000000)
 pid = self._counter
--- 39,43 ----
 os.rmdir(self._dir)
 
! def createMessage(self, dir, mbox=False):
 t = int(time.time() % 1000000)
 pid = self._counter
***************
*** 48,51 ****
--- 48,53 ----
 fp = open(tmpname, "w")
 self._msgfiles.append(tmpname)
+ if mbox:
+ fp.write(FROM_)
 fp.write(DUMMY_MESSAGE)
 fp.close()
***************
*** 57,60 ****
--- 59,63 ----
 fp.close()
 self._msgfiles.append(newname)
+ return tmpname
 
 def test_empty_maildir(self):
***************
*** 94,97 ****
--- 97,112 ----
 self.assert_(self.mbox.next() is None)
 
+ def test_unix_mbox(self):
+ ### should be better!
+ import email.Parser
+ fname = self.createMessage("cur", True)
+ n = 0
+ for msg in mailbox.PortableUnixMailbox(open(fname),
+ email.Parser.Parser().parse):
+ n += 1
+ self.assertEqual(msg["subject"], "Simple Test")
+ self.assertEqual(len(str(msg)), len(FROM_)+len(DUMMY_MESSAGE))
+ self.assertEqual(n, 1)
+ 
 # XXX We still need more tests!
 


More information about the Python-checkins mailing list

AltStyle によって変換されたページ (->オリジナル) /