annotate Lib/test/test_old_mailbox.py @ 54294:dba767bc3155 legacy-trunk

remove mention of old ctypes version
author Benjamin Peterson <benjamin@python.org>
date Sat, 23 May 2009 20:59:09 +0000
parents 5dae0d7f683a
children a1b79778f22e 6768b2350c57
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
37915
ce2ec8c835e9 Make copy of test_mailbox.py. We'll still want to check the backward
Andrew M. Kuchling <amk@amk.ca>
parents: 32807
diff changeset
1 # This set of tests exercises the backward-compatibility class
ce2ec8c835e9 Make copy of test_mailbox.py. We'll still want to check the backward
Andrew M. Kuchling <amk@amk.ca>
parents: 32807
diff changeset
2 # in mailbox.py (the ones without write support).
ce2ec8c835e9 Make copy of test_mailbox.py. We'll still want to check the backward
Andrew M. Kuchling <amk@amk.ca>
parents: 32807
diff changeset
3
15298
85a509faccc7 Added test for regression on SourceForge bug #117490.
Fred Drake <fdrake@acm.org>
parents:
diff changeset
4 import mailbox
85a509faccc7 Added test for regression on SourceForge bug #117490.
Fred Drake <fdrake@acm.org>
parents:
diff changeset
5 import os
17885
a93daafbd13d Re-write the mailbox test suite to use PyUnit. Cover a lot more ground
Fred Drake <fdrake@acm.org>
parents: 17375
diff changeset
6 import time
a93daafbd13d Re-write the mailbox test suite to use PyUnit. Cover a lot more ground
Fred Drake <fdrake@acm.org>
parents: 17375
diff changeset
7 import unittest
24364
aa0d2d51fbde Get rid of relative imports in all unittests. Now anything that
Barry Warsaw <barry@python.org>
parents: 20654
diff changeset
8 from test import test_support
15298
85a509faccc7 Added test for regression on SourceForge bug #117490.
Fred Drake <fdrake@acm.org>
parents:
diff changeset
9
17885
a93daafbd13d Re-write the mailbox test suite to use PyUnit. Cover a lot more ground
Fred Drake <fdrake@acm.org>
parents: 17375
diff changeset
10 # cleanup earlier tests
17375
0c87ac674ce1 Some other tests, when failing, don't always remove their TESTFN file.
Guido van Rossum <guido@python.org>
parents: 16936
diff changeset
11 try:
0c87ac674ce1 Some other tests, when failing, don't always remove their TESTFN file.
Guido van Rossum <guido@python.org>
parents: 16936
diff changeset
12 os.unlink(test_support.TESTFN)
0c87ac674ce1 Some other tests, when failing, don't always remove their TESTFN file.
Guido van Rossum <guido@python.org>
parents: 16936
diff changeset
13 except os.error:
0c87ac674ce1 Some other tests, when failing, don't always remove their TESTFN file.
Guido van Rossum <guido@python.org>
parents: 16936
diff changeset
14 pass
0c87ac674ce1 Some other tests, when failing, don't always remove their TESTFN file.
Guido van Rossum <guido@python.org>
parents: 16936
diff changeset
15
32807
4a51cdcf8615 added test for bug #996359.
Skip Montanaro <skip@pobox.com>
parents: 24364
diff changeset
16 FROM_ = "From some.body@dummy.domain Sat Jul 24 13:43:35 2004\n"
17885
a93daafbd13d Re-write the mailbox test suite to use PyUnit. Cover a lot more ground
Fred Drake <fdrake@acm.org>
parents: 17375
diff changeset
17 DUMMY_MESSAGE = """\
a93daafbd13d Re-write the mailbox test suite to use PyUnit. Cover a lot more ground
Fred Drake <fdrake@acm.org>
parents: 17375
diff changeset
18 From: some.body@dummy.domain
a93daafbd13d Re-write the mailbox test suite to use PyUnit. Cover a lot more ground
Fred Drake <fdrake@acm.org>
parents: 17375
diff changeset
19 To: me@my.domain
32807
4a51cdcf8615 added test for bug #996359.
Skip Montanaro <skip@pobox.com>
parents: 24364
diff changeset
20 Subject: Simple Test
17885
a93daafbd13d Re-write the mailbox test suite to use PyUnit. Cover a lot more ground
Fred Drake <fdrake@acm.org>
parents: 17375
diff changeset
21
a93daafbd13d Re-write the mailbox test suite to use PyUnit. Cover a lot more ground
Fred Drake <fdrake@acm.org>
parents: 17375
diff changeset
22 This is a dummy message.
a93daafbd13d Re-write the mailbox test suite to use PyUnit. Cover a lot more ground
Fred Drake <fdrake@acm.org>
parents: 17375
diff changeset
23 """
a93daafbd13d Re-write the mailbox test suite to use PyUnit. Cover a lot more ground
Fred Drake <fdrake@acm.org>
parents: 17375
diff changeset
24
a93daafbd13d Re-write the mailbox test suite to use PyUnit. Cover a lot more ground
Fred Drake <fdrake@acm.org>
parents: 17375
diff changeset
25 class MaildirTestCase(unittest.TestCase):
a93daafbd13d Re-write the mailbox test suite to use PyUnit. Cover a lot more ground
Fred Drake <fdrake@acm.org>
parents: 17375
diff changeset
26
a93daafbd13d Re-write the mailbox test suite to use PyUnit. Cover a lot more ground
Fred Drake <fdrake@acm.org>
parents: 17375
diff changeset
27 def setUp(self):
a93daafbd13d Re-write the mailbox test suite to use PyUnit. Cover a lot more ground
Fred Drake <fdrake@acm.org>
parents: 17375
diff changeset
28 # create a new maildir mailbox to work with:
a93daafbd13d Re-write the mailbox test suite to use PyUnit. Cover a lot more ground
Fred Drake <fdrake@acm.org>
parents: 17375
diff changeset
29 self._dir = test_support.TESTFN
a93daafbd13d Re-write the mailbox test suite to use PyUnit. Cover a lot more ground
Fred Drake <fdrake@acm.org>
parents: 17375
diff changeset
30 os.mkdir(self._dir)
a93daafbd13d Re-write the mailbox test suite to use PyUnit. Cover a lot more ground
Fred Drake <fdrake@acm.org>
parents: 17375
diff changeset
31 os.mkdir(os.path.join(self._dir, "cur"))
a93daafbd13d Re-write the mailbox test suite to use PyUnit. Cover a lot more ground
Fred Drake <fdrake@acm.org>
parents: 17375
diff changeset
32 os.mkdir(os.path.join(self._dir, "tmp"))
a93daafbd13d Re-write the mailbox test suite to use PyUnit. Cover a lot more ground
Fred Drake <fdrake@acm.org>
parents: 17375
diff changeset
33 os.mkdir(os.path.join(self._dir, "new"))
a93daafbd13d Re-write the mailbox test suite to use PyUnit. Cover a lot more ground
Fred Drake <fdrake@acm.org>
parents: 17375
diff changeset
34 self._counter = 1
a93daafbd13d Re-write the mailbox test suite to use PyUnit. Cover a lot more ground
Fred Drake <fdrake@acm.org>
parents: 17375
diff changeset
35 self._msgfiles = []
a93daafbd13d Re-write the mailbox test suite to use PyUnit. Cover a lot more ground
Fred Drake <fdrake@acm.org>
parents: 17375
diff changeset
36
a93daafbd13d Re-write the mailbox test suite to use PyUnit. Cover a lot more ground
Fred Drake <fdrake@acm.org>
parents: 17375
diff changeset
37 def tearDown(self):
a93daafbd13d Re-write the mailbox test suite to use PyUnit. Cover a lot more ground
Fred Drake <fdrake@acm.org>
parents: 17375
diff changeset
38 map(os.unlink, self._msgfiles)
a93daafbd13d Re-write the mailbox test suite to use PyUnit. Cover a lot more ground
Fred Drake <fdrake@acm.org>
parents: 17375
diff changeset
39 os.rmdir(os.path.join(self._dir, "cur"))
a93daafbd13d Re-write the mailbox test suite to use PyUnit. Cover a lot more ground
Fred Drake <fdrake@acm.org>
parents: 17375
diff changeset
40 os.rmdir(os.path.join(self._dir, "tmp"))
a93daafbd13d Re-write the mailbox test suite to use PyUnit. Cover a lot more ground
Fred Drake <fdrake@acm.org>
parents: 17375
diff changeset
41 os.rmdir(os.path.join(self._dir, "new"))
a93daafbd13d Re-write the mailbox test suite to use PyUnit. Cover a lot more ground
Fred Drake <fdrake@acm.org>
parents: 17375
diff changeset
42 os.rmdir(self._dir)
15298
85a509faccc7 Added test for regression on SourceForge bug #117490.
Fred Drake <fdrake@acm.org>
parents:
diff changeset
43
32807
4a51cdcf8615 added test for bug #996359.
Skip Montanaro <skip@pobox.com>
parents: 24364
diff changeset
44 def createMessage(self, dir, mbox=False):
18165
0bad42e56320 The test used int(time.time()) to get a random number, but this doesn't work on the mac (where times are bigger than ints). Changed to int(time.time()%1000000).
Jack Jansen <jack.jansen@cwi.nl>
parents: 17908
diff changeset
45 t = int(time.time() % 1000000)
17885
a93daafbd13d Re-write the mailbox test suite to use PyUnit. Cover a lot more ground
Fred Drake <fdrake@acm.org>
parents: 17375
diff changeset
46 pid = self._counter
a93daafbd13d Re-write the mailbox test suite to use PyUnit. Cover a lot more ground
Fred Drake <fdrake@acm.org>
parents: 17375
diff changeset
47 self._counter += 1
20654
edd9d0b3c47e SF patch #474590 -- RISC OS support
Guido van Rossum <guido@python.org>
parents: 20013
diff changeset
48 filename = os.extsep.join((str(t), str(pid), "myhostname", "mydomain"))
17885
a93daafbd13d Re-write the mailbox test suite to use PyUnit. Cover a lot more ground
Fred Drake <fdrake@acm.org>
parents: 17375
diff changeset
49 tmpname = os.path.join(self._dir, "tmp", filename)
a93daafbd13d Re-write the mailbox test suite to use PyUnit. Cover a lot more ground
Fred Drake <fdrake@acm.org>
parents: 17375
diff changeset
50 newname = os.path.join(self._dir, dir, filename)
a93daafbd13d Re-write the mailbox test suite to use PyUnit. Cover a lot more ground
Fred Drake <fdrake@acm.org>
parents: 17375
diff changeset
51 fp = open(tmpname, "w")
a93daafbd13d Re-write the mailbox test suite to use PyUnit. Cover a lot more ground
Fred Drake <fdrake@acm.org>
parents: 17375
diff changeset
52 self._msgfiles.append(tmpname)
32807
4a51cdcf8615 added test for bug #996359.
Skip Montanaro <skip@pobox.com>
parents: 24364
diff changeset
53 if mbox:
4a51cdcf8615 added test for bug #996359.
Skip Montanaro <skip@pobox.com>
parents: 24364
diff changeset
54 fp.write(FROM_)
17885
a93daafbd13d Re-write the mailbox test suite to use PyUnit. Cover a lot more ground
Fred Drake <fdrake@acm.org>
parents: 17375
diff changeset
55 fp.write(DUMMY_MESSAGE)
a93daafbd13d Re-write the mailbox test suite to use PyUnit. Cover a lot more ground
Fred Drake <fdrake@acm.org>
parents: 17375
diff changeset
56 fp.close()
17908
d884235fe75c create_message(): When os.link() doesn't exist, make a copy of the msg
Tim Peters <tim.peters@gmail.com>
parents: 17885
diff changeset
57 if hasattr(os, "link"):
d884235fe75c create_message(): When os.link() doesn't exist, make a copy of the msg
Tim Peters <tim.peters@gmail.com>
parents: 17885
diff changeset
58 os.link(tmpname, newname)
d884235fe75c create_message(): When os.link() doesn't exist, make a copy of the msg
Tim Peters <tim.peters@gmail.com>
parents: 17885
diff changeset
59 else:
d884235fe75c create_message(): When os.link() doesn't exist, make a copy of the msg
Tim Peters <tim.peters@gmail.com>
parents: 17885
diff changeset
60 fp = open(newname, "w")
d884235fe75c create_message(): When os.link() doesn't exist, make a copy of the msg
Tim Peters <tim.peters@gmail.com>
parents: 17885
diff changeset
61 fp.write(DUMMY_MESSAGE)
d884235fe75c create_message(): When os.link() doesn't exist, make a copy of the msg
Tim Peters <tim.peters@gmail.com>
parents: 17885
diff changeset
62 fp.close()
17885
a93daafbd13d Re-write the mailbox test suite to use PyUnit. Cover a lot more ground
Fred Drake <fdrake@acm.org>
parents: 17375
diff changeset
63 self._msgfiles.append(newname)
32807
4a51cdcf8615 added test for bug #996359.
Skip Montanaro <skip@pobox.com>
parents: 24364
diff changeset
64 return tmpname
17885
a93daafbd13d Re-write the mailbox test suite to use PyUnit. Cover a lot more ground
Fred Drake <fdrake@acm.org>
parents: 17375
diff changeset
65
a93daafbd13d Re-write the mailbox test suite to use PyUnit. Cover a lot more ground
Fred Drake <fdrake@acm.org>
parents: 17375
diff changeset
66 def test_empty_maildir(self):
a93daafbd13d Re-write the mailbox test suite to use PyUnit. Cover a lot more ground
Fred Drake <fdrake@acm.org>
parents: 17375
diff changeset
67 """Test an empty maildir mailbox"""
a93daafbd13d Re-write the mailbox test suite to use PyUnit. Cover a lot more ground
Fred Drake <fdrake@acm.org>
parents: 17375
diff changeset
68 # Test for regression on bug #117490:
a93daafbd13d Re-write the mailbox test suite to use PyUnit. Cover a lot more ground
Fred Drake <fdrake@acm.org>
parents: 17375
diff changeset
69 self.mbox = mailbox.Maildir(test_support.TESTFN)
37915
ce2ec8c835e9 Make copy of test_mailbox.py. We'll still want to check the backward
Andrew M. Kuchling <amk@amk.ca>
parents: 32807
diff changeset
70 self.assert_(len(self.mbox) == 0)
17885
a93daafbd13d Re-write the mailbox test suite to use PyUnit. Cover a lot more ground
Fred Drake <fdrake@acm.org>
parents: 17375
diff changeset
71 self.assert_(self.mbox.next() is None)
a93daafbd13d Re-write the mailbox test suite to use PyUnit. Cover a lot more ground
Fred Drake <fdrake@acm.org>
parents: 17375
diff changeset
72 self.assert_(self.mbox.next() is None)
a93daafbd13d Re-write the mailbox test suite to use PyUnit. Cover a lot more ground
Fred Drake <fdrake@acm.org>
parents: 17375
diff changeset
73
a93daafbd13d Re-write the mailbox test suite to use PyUnit. Cover a lot more ground
Fred Drake <fdrake@acm.org>
parents: 17375
diff changeset
74 def test_nonempty_maildir_cur(self):
a93daafbd13d Re-write the mailbox test suite to use PyUnit. Cover a lot more ground
Fred Drake <fdrake@acm.org>
parents: 17375
diff changeset
75 self.createMessage("cur")
a93daafbd13d Re-write the mailbox test suite to use PyUnit. Cover a lot more ground
Fred Drake <fdrake@acm.org>
parents: 17375
diff changeset
76 self.mbox = mailbox.Maildir(test_support.TESTFN)
37915
ce2ec8c835e9 Make copy of test_mailbox.py. We'll still want to check the backward
Andrew M. Kuchling <amk@amk.ca>
parents: 32807
diff changeset
77 self.assert_(len(self.mbox) == 1)
17885
a93daafbd13d Re-write the mailbox test suite to use PyUnit. Cover a lot more ground
Fred Drake <fdrake@acm.org>
parents: 17375
diff changeset
78 self.assert_(self.mbox.next() is not None)
a93daafbd13d Re-write the mailbox test suite to use PyUnit. Cover a lot more ground
Fred Drake <fdrake@acm.org>
parents: 17375
diff changeset
79 self.assert_(self.mbox.next() is None)
a93daafbd13d Re-write the mailbox test suite to use PyUnit. Cover a lot more ground
Fred Drake <fdrake@acm.org>
parents: 17375
diff changeset
80 self.assert_(self.mbox.next() is None)
a93daafbd13d Re-write the mailbox test suite to use PyUnit. Cover a lot more ground
Fred Drake <fdrake@acm.org>
parents: 17375
diff changeset
81
a93daafbd13d Re-write the mailbox test suite to use PyUnit. Cover a lot more ground
Fred Drake <fdrake@acm.org>
parents: 17375
diff changeset
82 def test_nonempty_maildir_new(self):
a93daafbd13d Re-write the mailbox test suite to use PyUnit. Cover a lot more ground
Fred Drake <fdrake@acm.org>
parents: 17375
diff changeset
83 self.createMessage("new")
a93daafbd13d Re-write the mailbox test suite to use PyUnit. Cover a lot more ground
Fred Drake <fdrake@acm.org>
parents: 17375
diff changeset
84 self.mbox = mailbox.Maildir(test_support.TESTFN)
37915
ce2ec8c835e9 Make copy of test_mailbox.py. We'll still want to check the backward
Andrew M. Kuchling <amk@amk.ca>
parents: 32807
diff changeset
85 self.assert_(len(self.mbox) == 1)
17885
a93daafbd13d Re-write the mailbox test suite to use PyUnit. Cover a lot more ground
Fred Drake <fdrake@acm.org>
parents: 17375
diff changeset
86 self.assert_(self.mbox.next() is not None)
a93daafbd13d Re-write the mailbox test suite to use PyUnit. Cover a lot more ground
Fred Drake <fdrake@acm.org>
parents: 17375
diff changeset
87 self.assert_(self.mbox.next() is None)
a93daafbd13d Re-write the mailbox test suite to use PyUnit. Cover a lot more ground
Fred Drake <fdrake@acm.org>
parents: 17375
diff changeset
88 self.assert_(self.mbox.next() is None)
a93daafbd13d Re-write the mailbox test suite to use PyUnit. Cover a lot more ground
Fred Drake <fdrake@acm.org>
parents: 17375
diff changeset
89
a93daafbd13d Re-write the mailbox test suite to use PyUnit. Cover a lot more ground
Fred Drake <fdrake@acm.org>
parents: 17375
diff changeset
90 def test_nonempty_maildir_both(self):
a93daafbd13d Re-write the mailbox test suite to use PyUnit. Cover a lot more ground
Fred Drake <fdrake@acm.org>
parents: 17375
diff changeset
91 self.createMessage("cur")
a93daafbd13d Re-write the mailbox test suite to use PyUnit. Cover a lot more ground
Fred Drake <fdrake@acm.org>
parents: 17375
diff changeset
92 self.createMessage("new")
a93daafbd13d Re-write the mailbox test suite to use PyUnit. Cover a lot more ground
Fred Drake <fdrake@acm.org>
parents: 17375
diff changeset
93 self.mbox = mailbox.Maildir(test_support.TESTFN)
37915
ce2ec8c835e9 Make copy of test_mailbox.py. We'll still want to check the backward
Andrew M. Kuchling <amk@amk.ca>
parents: 32807
diff changeset
94 self.assert_(len(self.mbox) == 2)
17885
a93daafbd13d Re-write the mailbox test suite to use PyUnit. Cover a lot more ground
Fred Drake <fdrake@acm.org>
parents: 17375
diff changeset
95 self.assert_(self.mbox.next() is not None)
a93daafbd13d Re-write the mailbox test suite to use PyUnit. Cover a lot more ground
Fred Drake <fdrake@acm.org>
parents: 17375
diff changeset
96 self.assert_(self.mbox.next() is not None)
a93daafbd13d Re-write the mailbox test suite to use PyUnit. Cover a lot more ground
Fred Drake <fdrake@acm.org>
parents: 17375
diff changeset
97 self.assert_(self.mbox.next() is None)
a93daafbd13d Re-write the mailbox test suite to use PyUnit. Cover a lot more ground
Fred Drake <fdrake@acm.org>
parents: 17375
diff changeset
98 self.assert_(self.mbox.next() is None)
15298
85a509faccc7 Added test for regression on SourceForge bug #117490.
Fred Drake <fdrake@acm.org>
parents:
diff changeset
99
32807
4a51cdcf8615 added test for bug #996359.
Skip Montanaro <skip@pobox.com>
parents: 24364
diff changeset
100 def test_unix_mbox(self):
4a51cdcf8615 added test for bug #996359.
Skip Montanaro <skip@pobox.com>
parents: 24364
diff changeset
101 ### should be better!
4a51cdcf8615 added test for bug #996359.
Skip Montanaro <skip@pobox.com>
parents: 24364
diff changeset
102 import email.Parser
4a51cdcf8615 added test for bug #996359.
Skip Montanaro <skip@pobox.com>
parents: 24364
diff changeset
103 fname = self.createMessage("cur", True)
4a51cdcf8615 added test for bug #996359.
Skip Montanaro <skip@pobox.com>
parents: 24364
diff changeset
104 n = 0
4a51cdcf8615 added test for bug #996359.
Skip Montanaro <skip@pobox.com>
parents: 24364
diff changeset
105 for msg in mailbox.PortableUnixMailbox(open(fname),
4a51cdcf8615 added test for bug #996359.
Skip Montanaro <skip@pobox.com>
parents: 24364
diff changeset
106 email.Parser.Parser().parse):
4a51cdcf8615 added test for bug #996359.
Skip Montanaro <skip@pobox.com>
parents: 24364
diff changeset
107 n += 1
4a51cdcf8615 added test for bug #996359.
Skip Montanaro <skip@pobox.com>
parents: 24364
diff changeset
108 self.assertEqual(msg["subject"], "Simple Test")
4a51cdcf8615 added test for bug #996359.
Skip Montanaro <skip@pobox.com>
parents: 24364
diff changeset
109 self.assertEqual(len(str(msg)), len(FROM_)+len(DUMMY_MESSAGE))
4a51cdcf8615 added test for bug #996359.
Skip Montanaro <skip@pobox.com>
parents: 24364
diff changeset
110 self.assertEqual(n, 1)
4a51cdcf8615 added test for bug #996359.
Skip Montanaro <skip@pobox.com>
parents: 24364
diff changeset
111
40690
bb4c0bbba272 Improve pattern used for mbox 'From' lines; add a simple test
Andrew M. Kuchling <amk@amk.ca>
parents: 37915
diff changeset
112 class MboxTestCase(unittest.TestCase):
bb4c0bbba272 Improve pattern used for mbox 'From' lines; add a simple test
Andrew M. Kuchling <amk@amk.ca>
parents: 37915
diff changeset
113 def setUp(self):
bb4c0bbba272 Improve pattern used for mbox 'From' lines; add a simple test
Andrew M. Kuchling <amk@amk.ca>
parents: 37915
diff changeset
114 # create a new maildir mailbox to work with:
bb4c0bbba272 Improve pattern used for mbox 'From' lines; add a simple test
Andrew M. Kuchling <amk@amk.ca>
parents: 37915
diff changeset
115 self._path = test_support.TESTFN
bb4c0bbba272 Improve pattern used for mbox 'From' lines; add a simple test
Andrew M. Kuchling <amk@amk.ca>
parents: 37915
diff changeset
116
bb4c0bbba272 Improve pattern used for mbox 'From' lines; add a simple test
Andrew M. Kuchling <amk@amk.ca>
parents: 37915
diff changeset
117 def tearDown(self):
bb4c0bbba272 Improve pattern used for mbox 'From' lines; add a simple test
Andrew M. Kuchling <amk@amk.ca>
parents: 37915
diff changeset
118 os.unlink(self._path)
40732
5dae0d7f683a Whitespace normalization.
Tim Peters <tim.peters@gmail.com>
parents: 40690
diff changeset
119
40690
bb4c0bbba272 Improve pattern used for mbox 'From' lines; add a simple test
Andrew M. Kuchling <amk@amk.ca>
parents: 37915
diff changeset
120 def test_from_regex (self):
bb4c0bbba272 Improve pattern used for mbox 'From' lines; add a simple test
Andrew M. Kuchling <amk@amk.ca>
parents: 37915
diff changeset
121 # Testing new regex from bug #1633678
bb4c0bbba272 Improve pattern used for mbox 'From' lines; add a simple test
Andrew M. Kuchling <amk@amk.ca>
parents: 37915
diff changeset
122 f = open(self._path, 'w')
bb4c0bbba272 Improve pattern used for mbox 'From' lines; add a simple test
Andrew M. Kuchling <amk@amk.ca>
parents: 37915
diff changeset
123 f.write("""From fred@example.com Mon May 31 13:24:50 2004 +0200
bb4c0bbba272 Improve pattern used for mbox 'From' lines; add a simple test
Andrew M. Kuchling <amk@amk.ca>
parents: 37915
diff changeset
124 Subject: message 1
bb4c0bbba272 Improve pattern used for mbox 'From' lines; add a simple test
Andrew M. Kuchling <amk@amk.ca>
parents: 37915
diff changeset
125
bb4c0bbba272 Improve pattern used for mbox 'From' lines; add a simple test
Andrew M. Kuchling <amk@amk.ca>
parents: 37915
diff changeset
126 body1
bb4c0bbba272 Improve pattern used for mbox 'From' lines; add a simple test
Andrew M. Kuchling <amk@amk.ca>
parents: 37915
diff changeset
127 From fred@example.com Mon May 31 13:24:50 2004 -0200
bb4c0bbba272 Improve pattern used for mbox 'From' lines; add a simple test
Andrew M. Kuchling <amk@amk.ca>
parents: 37915
diff changeset
128 Subject: message 2
bb4c0bbba272 Improve pattern used for mbox 'From' lines; add a simple test
Andrew M. Kuchling <amk@amk.ca>
parents: 37915
diff changeset
129
bb4c0bbba272 Improve pattern used for mbox 'From' lines; add a simple test
Andrew M. Kuchling <amk@amk.ca>
parents: 37915
diff changeset
130 body2
bb4c0bbba272 Improve pattern used for mbox 'From' lines; add a simple test
Andrew M. Kuchling <amk@amk.ca>
parents: 37915
diff changeset
131 From fred@example.com Mon May 31 13:24:50 2004
bb4c0bbba272 Improve pattern used for mbox 'From' lines; add a simple test
Andrew M. Kuchling <amk@amk.ca>
parents: 37915
diff changeset
132 Subject: message 3
bb4c0bbba272 Improve pattern used for mbox 'From' lines; add a simple test
Andrew M. Kuchling <amk@amk.ca>
parents: 37915
diff changeset
133
bb4c0bbba272 Improve pattern used for mbox 'From' lines; add a simple test
Andrew M. Kuchling <amk@amk.ca>
parents: 37915
diff changeset
134 body3
bb4c0bbba272 Improve pattern used for mbox 'From' lines; add a simple test
Andrew M. Kuchling <amk@amk.ca>
parents: 37915
diff changeset
135 From fred@example.com Mon May 31 13:24:50 2004
bb4c0bbba272 Improve pattern used for mbox 'From' lines; add a simple test
Andrew M. Kuchling <amk@amk.ca>
parents: 37915
diff changeset
136 Subject: message 4
bb4c0bbba272 Improve pattern used for mbox 'From' lines; add a simple test
Andrew M. Kuchling <amk@amk.ca>
parents: 37915
diff changeset
137
bb4c0bbba272 Improve pattern used for mbox 'From' lines; add a simple test
Andrew M. Kuchling <amk@amk.ca>
parents: 37915
diff changeset
138 body4
bb4c0bbba272 Improve pattern used for mbox 'From' lines; add a simple test
Andrew M. Kuchling <amk@amk.ca>
parents: 37915
diff changeset
139 """)
bb4c0bbba272 Improve pattern used for mbox 'From' lines; add a simple test
Andrew M. Kuchling <amk@amk.ca>
parents: 37915
diff changeset
140 f.close()
bb4c0bbba272 Improve pattern used for mbox 'From' lines; add a simple test
Andrew M. Kuchling <amk@amk.ca>
parents: 37915
diff changeset
141 box = mailbox.UnixMailbox(open(self._path, 'r'))
bb4c0bbba272 Improve pattern used for mbox 'From' lines; add a simple test
Andrew M. Kuchling <amk@amk.ca>
parents: 37915
diff changeset
142 self.assert_(len(list(iter(box))) == 4)
bb4c0bbba272 Improve pattern used for mbox 'From' lines; add a simple test
Andrew M. Kuchling <amk@amk.ca>
parents: 37915
diff changeset
143
bb4c0bbba272 Improve pattern used for mbox 'From' lines; add a simple test
Andrew M. Kuchling <amk@amk.ca>
parents: 37915
diff changeset
144
15298
85a509faccc7 Added test for regression on SourceForge bug #117490.
Fred Drake <fdrake@acm.org>
parents:
diff changeset
145 # XXX We still need more tests!
85a509faccc7 Added test for regression on SourceForge bug #117490.
Fred Drake <fdrake@acm.org>
parents:
diff changeset
146
17885
a93daafbd13d Re-write the mailbox test suite to use PyUnit. Cover a lot more ground
Fred Drake <fdrake@acm.org>
parents: 17375
diff changeset
147
20013
e3184e46303b Change the PyUnit-based tests to use the test_main() approach. This
Fred Drake <fdrake@acm.org>
parents: 18165
diff changeset
148 def test_main():
40690
bb4c0bbba272 Improve pattern used for mbox 'From' lines; add a simple test
Andrew M. Kuchling <amk@amk.ca>
parents: 37915
diff changeset
149 test_support.run_unittest(MaildirTestCase, MboxTestCase)
20013
e3184e46303b Change the PyUnit-based tests to use the test_main() approach. This
Fred Drake <fdrake@acm.org>
parents: 18165
diff changeset
150
e3184e46303b Change the PyUnit-based tests to use the test_main() approach. This
Fred Drake <fdrake@acm.org>
parents: 18165
diff changeset
151
e3184e46303b Change the PyUnit-based tests to use the test_main() approach. This
Fred Drake <fdrake@acm.org>
parents: 18165
diff changeset
152 if __name__ == "__main__":
e3184e46303b Change the PyUnit-based tests to use the test_main() approach. This
Fred Drake <fdrake@acm.org>
parents: 18165
diff changeset
153 test_main()