Bug 1277: make Maildir use the user-provided factory instead of hard-wiring MaildirMessage.
diff --git a/Lib/test/test_mailbox.py b/Lib/test/test_mailbox.py
index 57e44f4..ffeeb3e 100644
--- a/Lib/test/test_mailbox.py
+++ b/Lib/test/test_mailbox.py
@@ -508,6 +508,20 @@
         self.assert_(msg_returned.get_flags() == 'S')
         self.assert_(msg_returned.get_payload() == '3')
 
+    def test_consistent_factory(self):
+        # Add a message.
+        msg = mailbox.MaildirMessage(self._template % 0)
+        msg.set_subdir('cur')
+        msg.set_flags('RF')
+        key = self._box.add(msg)
+
+        # Create new mailbox with
+        class FakeMessage(mailbox.MaildirMessage):
+            pass
+        box = mailbox.Maildir(self._path, factory=FakeMessage)
+        msg2 = box.get_message(key)
+        self.assert_(isinstance(msg2, FakeMessage))
+
     def test_initialize_new(self):
         # Initialize a non-existent mailbox
         self.tearDown()