summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_mailbox.py
diff options
context:
space:
mode:
authorBrett Cannon <bcannon@gmail.com>2010-10-30 00:13:00 (GMT)
committerBrett Cannon <bcannon@gmail.com>2010-10-30 00:13:00 (GMT)
commit653238a88db15c36a63ca70620f79ecd4b799d01 (patch)
treeb9561e924fc65b560b72a3d36e7d595e091b83b9 /Lib/test/test_mailbox.py
parentd05f9ad30231029da69286ed3dc8eba0002499df (diff)
downloadcpython-653238a88db15c36a63ca70620f79ecd4b799d01.zip
cpython-653238a88db15c36a63ca70620f79ecd4b799d01.tar.gz
cpython-653238a88db15c36a63ca70620f79ecd4b799d01.tar.bz2
Silence some ResourceWarning in test_mailbox by using file context managers.
Also call super().tearDown() where appropriate.
Diffstat (limited to 'Lib/test/test_mailbox.py')
-rw-r--r--Lib/test/test_mailbox.py8
1 files changed, 6 insertions, 2 deletions
diff --git a/Lib/test/test_mailbox.py b/Lib/test/test_mailbox.py
index 69e70ed..de6d4bd 100644
--- a/Lib/test/test_mailbox.py
+++ b/Lib/test/test_mailbox.py
@@ -165,8 +165,10 @@ class TestMailbox(TestBase):
# Get file representations of messages
key0 = self._box.add(self._template % 0)
key1 = self._box.add(_sample_message)
- data0 = self._box.get_file(key0).read()
- data1 = self._box.get_file(key1).read()
+ with self._box.get_file(key0) as file:
+ data0 = file.read()
+ with self._box.get_file(key1) as file:
+ data1 = file.read()
self.assertEqual(data0.replace(os.linesep, '\n'),
self._template % 0)
self.assertEqual(data1.replace(os.linesep, '\n'),
@@ -773,6 +775,7 @@ class TestMaildir(TestMailbox):
class _TestMboxMMDF(TestMailbox):
def tearDown(self):
+ super().tearDown()
self._box.close()
self._delete_recursively(self._path)
for lock_remnant in glob.glob(self._path + '.*'):
@@ -1027,6 +1030,7 @@ class TestBabyl(TestMailbox):
_factory = lambda self, path, factory=None: mailbox.Babyl(path, factory)
def tearDown(self):
+ super().tearDown()
self._box.close()
self._delete_recursively(self._path)
for lock_remnant in glob.glob(self._path + '.*'):