diff options
author | Petri Lehtinen <petri@digip.org> | 2012-09-25 19:00:32 (GMT) |
---|---|---|
committer | Petri Lehtinen <petri@digip.org> | 2012-09-25 19:02:06 (GMT) |
commit | f39884bb5a01c3fa9db74833d2d8a05bf0530315 (patch) | |
tree | f79b3eeaaac3713727c6e7c6f5d1828d571e47e3 /Lib/test/test_mailbox.py | |
parent | 468091954f9e9d46e9d4c7673a37ccb3b3b03eb5 (diff) | |
download | cpython-f39884bb5a01c3fa9db74833d2d8a05bf0530315.zip cpython-f39884bb5a01c3fa9db74833d2d8a05bf0530315.tar.gz cpython-f39884bb5a01c3fa9db74833d2d8a05bf0530315.tar.bz2 |
#15222: Insert blank line after each message in mbox mailboxes
Diffstat (limited to 'Lib/test/test_mailbox.py')
-rw-r--r-- | Lib/test/test_mailbox.py | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/Lib/test/test_mailbox.py b/Lib/test/test_mailbox.py index a9c4c70..c72eb1c 100644 --- a/Lib/test/test_mailbox.py +++ b/Lib/test/test_mailbox.py @@ -1113,6 +1113,29 @@ class TestMbox(_TestMboxMMDF, unittest.TestCase): perms = st.st_mode self.assertFalse((perms & 0o111)) # Execute bits should all be off. + def test_terminating_newline(self): + message = email.message.Message() + message['From'] = 'john@example.com' + message.set_payload('No newline at the end') + i = self._box.add(message) + + # A newline should have been appended to the payload + message = self._box.get(i) + self.assertEqual(message.get_payload(), 'No newline at the end\n') + + def test_message_separator(self): + # Check there's always a single blank line after each message + self._box.add('From: foo\n\n0') # No newline at the end + with open(self._path) as f: + data = f.read() + self.assertEqual(data[-3:], '0\n\n') + + self._box.add('From: foo\n\n0\n') # Newline at the end + with open(self._path) as f: + data = f.read() + self.assertEqual(data[-3:], '0\n\n') + + class TestMMDF(_TestMboxMMDF, unittest.TestCase): _factory = lambda self, path, factory=None: mailbox.MMDF(path, factory) |