[Python-checkins] r85960 - python/branches/py3k/Lib/test/test_mailbox.py
brett.cannon
python-checkins at python.org
Sat Oct 30 02:13:01 CEST 2010
Author: brett.cannon
Date: Sat Oct 30 02:13:00 2010
New Revision: 85960
Log:
Silence some ResourceWarning in test_mailbox by using file context managers.
Also call super().tearDown() where appropriate.
Modified:
python/branches/py3k/Lib/test/test_mailbox.py
Modified: python/branches/py3k/Lib/test/test_mailbox.py
==============================================================================
--- python/branches/py3k/Lib/test/test_mailbox.py (original)
+++ python/branches/py3k/Lib/test/test_mailbox.py Sat Oct 30 02:13:00 2010
@@ -165,8 +165,10 @@
# 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 _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 @@
_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 + '.*'):
More information about the Python-checkins
mailing list