diff options
author | Skip Montanaro <skip@pobox.com> | 2004-07-24 19:56:03 (GMT) |
---|---|---|
committer | Skip Montanaro <skip@pobox.com> | 2004-07-24 19:56:03 (GMT) |
commit | 5253da163c8faf789567ab0a709a176addb8d73d (patch) | |
tree | d2332245963c0eee7d0968d0fd1c598b459bd363 /Lib/test/test_mailbox.py | |
parent | 3414c1ceeebd6a0cc00df147cfd3146821010194 (diff) | |
download | cpython-5253da163c8faf789567ab0a709a176addb8d73d.zip cpython-5253da163c8faf789567ab0a709a176addb8d73d.tar.gz cpython-5253da163c8faf789567ab0a709a176addb8d73d.tar.bz2 |
added test for bug #996359.
Diffstat (limited to 'Lib/test/test_mailbox.py')
-rw-r--r-- | Lib/test/test_mailbox.py | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/Lib/test/test_mailbox.py b/Lib/test/test_mailbox.py index dc89fd8..77d39a6 100644 --- a/Lib/test/test_mailbox.py +++ b/Lib/test/test_mailbox.py @@ -10,15 +10,15 @@ try: except os.error: pass - +FROM_ = "From some.body@dummy.domain Sat Jul 24 13:43:35 2004\n" DUMMY_MESSAGE = """\ From: some.body@dummy.domain To: me@my.domain +Subject: Simple Test This is a dummy message. """ - class MaildirTestCase(unittest.TestCase): def setUp(self): @@ -38,7 +38,7 @@ class MaildirTestCase(unittest.TestCase): os.rmdir(os.path.join(self._dir, "new")) os.rmdir(self._dir) - def createMessage(self, dir): + def createMessage(self, dir, mbox=False): t = int(time.time() % 1000000) pid = self._counter self._counter += 1 @@ -47,6 +47,8 @@ class MaildirTestCase(unittest.TestCase): newname = os.path.join(self._dir, dir, filename) fp = open(tmpname, "w") self._msgfiles.append(tmpname) + if mbox: + fp.write(FROM_) fp.write(DUMMY_MESSAGE) fp.close() if hasattr(os, "link"): @@ -56,6 +58,7 @@ class MaildirTestCase(unittest.TestCase): fp.write(DUMMY_MESSAGE) fp.close() self._msgfiles.append(newname) + return tmpname def test_empty_maildir(self): """Test an empty maildir mailbox""" @@ -93,6 +96,18 @@ class MaildirTestCase(unittest.TestCase): self.assert_(self.mbox.next() is None) 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! |