summaryrefslogtreecommitdiffstats
path: root/Lib/email
diff options
context:
space:
mode:
authorBrett Cannon <bcannon@gmail.com>2010-10-29 23:08:36 (GMT)
committerBrett Cannon <bcannon@gmail.com>2010-10-29 23:08:36 (GMT)
commit384917a922766e93c9195cb3e500d8391a6abb08 (patch)
treeccaa12786e5ad19c92137295381d4331d3d8ae68 /Lib/email
parent06407b35b16cdd141a1cc6fdc122762add855279 (diff)
downloadcpython-384917a922766e93c9195cb3e500d8391a6abb08.zip
cpython-384917a922766e93c9195cb3e500d8391a6abb08.tar.gz
cpython-384917a922766e93c9195cb3e500d8391a6abb08.tar.bz2
Properly close files used by test_email.
Diffstat (limited to 'Lib/email')
-rw-r--r--Lib/email/test/test_email.py7
1 files changed, 4 insertions, 3 deletions
diff --git a/Lib/email/test/test_email.py b/Lib/email/test/test_email.py
index f40d770..34af777 100644
--- a/Lib/email/test/test_email.py
+++ b/Lib/email/test/test_email.py
@@ -182,8 +182,8 @@ class TestMessageAPI(TestEmailBase):
def test_message_rfc822_only(self):
# Issue 7970: message/rfc822 not in multipart parsed by
# HeaderParser caused an exception when flattened.
- fp = openfile(findfile('msg_46.txt'))
- msgdata = fp.read()
+ with openfile(findfile('msg_46.txt')) as fp:
+ msgdata = fp.read()
parser = HeaderParser()
msg = parser.parsestr(msgdata)
out = StringIO()
@@ -2897,7 +2897,8 @@ class Test8BitBytesHandling(unittest.TestCase):
self.addCleanup(unlink, fn)
with open(fn, 'wb') as testfile:
testfile.write(self.non_latin_bin_msg)
- m = email.parser.BytesParser().parse(open(fn, 'rb'))
+ with open(fn, 'rb') as testfile:
+ m = email.parser.BytesParser().parse(testfile)
self.assertEqual(str(m), self.non_latin_bin_msg_as7bit)
latin_bin_msg = textwrap.dedent("""\