summaryrefslogtreecommitdiff
path: root/Lib/test/test_old_mailbox.py
diff options
context:
space:
mode:
authorAndrew M. Kuchling <amk@amk.ca>2007-01-22 20:26:40 +0000
committerAndrew M. Kuchling <amk@amk.ca>2007-01-22 20:26:40 +0000
commitb78bb74c418767c2b5d046ccc85e0b106877a9f8 (patch)
tree49218f797e64249720b9848cb4b45744d7bc7533 /Lib/test/test_old_mailbox.py
parent5a096e1b100603f5537eca5124be17abacf17743 (diff)
downloadcpython-git-b78bb74c418767c2b5d046ccc85e0b106877a9f8.tar.gz
Improve pattern used for mbox 'From' lines; add a simple test
Diffstat (limited to 'Lib/test/test_old_mailbox.py')
-rw-r--r--Lib/test/test_old_mailbox.py35
1 files changed, 34 insertions, 1 deletions
diff --git a/Lib/test/test_old_mailbox.py b/Lib/test/test_old_mailbox.py
index cca6897961..c8f6bac64b 100644
--- a/Lib/test/test_old_mailbox.py
+++ b/Lib/test/test_old_mailbox.py
@@ -109,11 +109,44 @@ class MaildirTestCase(unittest.TestCase):
self.assertEqual(len(str(msg)), len(FROM_)+len(DUMMY_MESSAGE))
self.assertEqual(n, 1)
+class MboxTestCase(unittest.TestCase):
+ def setUp(self):
+ # create a new maildir mailbox to work with:
+ self._path = test_support.TESTFN
+
+ def tearDown(self):
+ os.unlink(self._path)
+
+ def test_from_regex (self):
+ # Testing new regex from bug #1633678
+ f = open(self._path, 'w')
+ f.write("""From fred@example.com Mon May 31 13:24:50 2004 +0200
+Subject: message 1
+
+body1
+From fred@example.com Mon May 31 13:24:50 2004 -0200
+Subject: message 2
+
+body2
+From fred@example.com Mon May 31 13:24:50 2004
+Subject: message 3
+
+body3
+From fred@example.com Mon May 31 13:24:50 2004
+Subject: message 4
+
+body4
+""")
+ f.close()
+ box = mailbox.UnixMailbox(open(self._path, 'r'))
+ self.assert_(len(list(iter(box))) == 4)
+
+
# XXX We still need more tests!
def test_main():
- test_support.run_unittest(MaildirTestCase)
+ test_support.run_unittest(MaildirTestCase, MboxTestCase)
if __name__ == "__main__":