added test for bug #996359.
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 @@
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 @@
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 @@
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 @@
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 @@
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!