summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorNeal Norwitz <nnorwitz@gmail.com>2008-03-26 05:19:41 (GMT)
committerNeal Norwitz <nnorwitz@gmail.com>2008-03-26 05:19:41 (GMT)
commit22b3e3aff82fe0ab4b643c038744de907412c7bc (patch)
tree3b796b9448d4fad772f090aa276dd276bec4ed9b /Lib
parent14f0bc79009b211e2ef8076c1ef6cfd193fd4cc6 (diff)
downloadcpython-22b3e3aff82fe0ab4b643c038744de907412c7bc.zip
cpython-22b3e3aff82fe0ab4b643c038744de907412c7bc.tar.gz
cpython-22b3e3aff82fe0ab4b643c038744de907412c7bc.tar.bz2
Ensure that the mailbox is closed to prevent problems on Windows with removing
an open file. This doesn't seem to be a problem in 2.6, but that appears to be somewhat accidental (specific to reference counting). When this gets merged to 3.0, it will make the 3.0 code simpler.
Diffstat (limited to 'Lib')
-rw-r--r--Lib/test/test_mailbox.py8
1 files changed, 5 insertions, 3 deletions
diff --git a/Lib/test/test_mailbox.py b/Lib/test/test_mailbox.py
index 9206dc4..83802c1 100644
--- a/Lib/test/test_mailbox.py
+++ b/Lib/test/test_mailbox.py
@@ -379,7 +379,7 @@ class TestMailbox(TestBase):
def test_flush(self):
# Write changes to disk
- self._test_flush_or_close(self._box.flush)
+ self._test_flush_or_close(self._box.flush, True)
def test_lock_unlock(self):
# Lock and unlock the mailbox
@@ -391,14 +391,16 @@ class TestMailbox(TestBase):
def test_close(self):
# Close mailbox and flush changes to disk
- self._test_flush_or_close(self._box.close)
+ self._test_flush_or_close(self._box.close, False)
- def _test_flush_or_close(self, method):
+ def _test_flush_or_close(self, method, should_call_close):
contents = [self._template % i for i in xrange(3)]
self._box.add(contents[0])
self._box.add(contents[1])
self._box.add(contents[2])
method()
+ if should_call_close:
+ self._box.close()
self._box = self._factory(self._path)
keys = self._box.keys()
self.assert_(len(keys) == 3)