summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_mailbox.py
diff options
context:
space:
mode:
authorAndrew M. Kuchling <amk@amk.ca>2006-11-09 13:27:07 (GMT)
committerAndrew M. Kuchling <amk@amk.ca>2006-11-09 13:27:07 (GMT)
commita3e5d3757c375ded62c3f64d4f3ed65881994e3c (patch)
treef5a3034b83c86eb669fb6f014f7501cc91ef9fc6 /Lib/test/test_mailbox.py
parent038cad7ee439f1f056170b0c97144cbdb6df6e41 (diff)
downloadcpython-a3e5d3757c375ded62c3f64d4f3ed65881994e3c.zip
cpython-a3e5d3757c375ded62c3f64d4f3ed65881994e3c.tar.gz
cpython-a3e5d3757c375ded62c3f64d4f3ed65881994e3c.tar.bz2
[Bug #1569790] mailbox.Maildir.get_folder() loses factory information
Both the Maildir and MH classes had this bug; the patch fixes both classes and adds a test. Will backport to 25-maint.
Diffstat (limited to 'Lib/test/test_mailbox.py')
-rw-r--r--Lib/test/test_mailbox.py24
1 files changed, 23 insertions, 1 deletions
diff --git a/Lib/test/test_mailbox.py b/Lib/test/test_mailbox.py
index ab164d0..2434dbc 100644
--- a/Lib/test/test_mailbox.py
+++ b/Lib/test/test_mailbox.py
@@ -673,6 +673,19 @@ class TestMaildir(TestMailbox):
self._box.lock()
self._box.unlock()
+ def test_folder (self):
+ # Test for bug #1569790: verify that folders returned by .get_folder()
+ # use the same factory function.
+ def dummy_factory (s):
+ return None
+ box = self._factory(self._path, factory=dummy_factory)
+ folder = box.add_folder('folder1')
+ self.assert_(folder._factory is dummy_factory)
+
+ folder1_alias = box.get_folder('folder1')
+ self.assert_(folder1_alias._factory is dummy_factory)
+
+
class _TestMboxMMDF(TestMailbox):
@@ -789,7 +802,11 @@ class TestMH(TestMailbox):
def test_get_folder(self):
# Open folders
- self._box.add_folder('foo.bar')
+ def dummy_factory (s):
+ return None
+ self._box = self._factory(self._path, dummy_factory)
+
+ new_folder = self._box.add_folder('foo.bar')
folder0 = self._box.get_folder('foo.bar')
folder0.add(self._template % 'bar')
self.assert_(os.path.isdir(os.path.join(self._path, 'foo.bar')))
@@ -797,6 +814,11 @@ class TestMH(TestMailbox):
self.assert_(folder1.get_string(folder1.keys()[0]) == \
self._template % 'bar')
+ # Test for bug #1569790: verify that folders returned by .get_folder()
+ # use the same factory function.
+ self.assert_(new_folder._factory is self._box._factory)
+ self.assert_(folder0._factory is self._box._factory)
+
def test_add_and_remove_folders(self):
# Delete folders
self._box.add_folder('one')