mirror of
https://github.com/python/cpython.git
synced 2025-09-26 10:19:53 +00:00
#11062: Fix adding a message from file to Babyl mailbox
This commit is contained in:
parent
becfcc0a6b
commit
2d44ceeada
3 changed files with 16 additions and 1 deletions
|
@ -8,6 +8,7 @@ import email.message
|
|||
import re
|
||||
import shutil
|
||||
import StringIO
|
||||
import tempfile
|
||||
from test import test_support
|
||||
import unittest
|
||||
import mailbox
|
||||
|
@ -75,6 +76,18 @@ class TestMailbox(TestBase):
|
|||
for i in (1, 2, 3, 4):
|
||||
self._check_sample(self._box[keys[i]])
|
||||
|
||||
def test_add_file(self):
|
||||
with tempfile.TemporaryFile('w+') as f:
|
||||
f.write(_sample_message)
|
||||
f.seek(0)
|
||||
key = self._box.add(f)
|
||||
self.assertEqual(self._box.get_string(key).split('\n'),
|
||||
_sample_message.split('\n'))
|
||||
|
||||
def test_add_StringIO(self):
|
||||
key = self._box.add(StringIO.StringIO(self._template % "0"))
|
||||
self.assertEqual(self._box.get_string(key), self._template % "0")
|
||||
|
||||
def test_remove(self):
|
||||
# Remove messages using remove()
|
||||
self._test_remove_or_delitem(self._box.remove)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue