mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
#15222: Insert blank line after each message in mbox mailboxes
This commit is contained in:
parent
468091954f
commit
f39884bb5a
3 changed files with 63 additions and 6 deletions
|
@ -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)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue