diff options
author | R David Murray <rdmurray@bitdance.com> | 2011-06-17 22:23:04 -0400 |
---|---|---|
committer | R David Murray <rdmurray@bitdance.com> | 2011-06-17 22:23:04 -0400 |
commit | f1138bb1b6ead7ddeae3e38e3c507d63d09669c3 (patch) | |
tree | e2d0369d88eb7945d5b86ffe2439d96639dc0554 /Lib/test/test_mailbox.py | |
parent | c74a6ba2d6c1f331896cf8dacc698b0b88c7e670 (diff) | |
download | cpython-git-f1138bb1b6ead7ddeae3e38e3c507d63d09669c3.tar.gz |
#11700: proxy object close methods can now be called multiple times
This makes them work like the close provided by regular file objects. This
patch also backports the close-the-underlying-file code for _ProxyFile objects
that was introduced along with context manager support in the 3.x branch.
Diffstat (limited to 'Lib/test/test_mailbox.py')
-rw-r--r-- | Lib/test/test_mailbox.py | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/Lib/test/test_mailbox.py b/Lib/test/test_mailbox.py index 3c7a3e6e6c..112497993c 100644 --- a/Lib/test/test_mailbox.py +++ b/Lib/test/test_mailbox.py @@ -174,6 +174,13 @@ class TestMailbox(TestBase): self.assertEqual(self._box.get_file(key1).read().replace(os.linesep, '\n'), _sample_message) + def test_get_file_can_be_closed_twice(self): + # Issue 11700 + key = self._box.add(_sample_message) + f = self._box.get_file(key) + f.close() + f.close() + def test_iterkeys(self): # Get keys using iterkeys() self._check_iteration(self._box.iterkeys, do_keys=True, do_values=False) @@ -1670,7 +1677,8 @@ class TestProxyFileBase(TestBase): def _test_close(self, proxy): # Close a file proxy.close() - self.assertRaises(AttributeError, lambda: proxy.close()) + # Issue 11700 subsequent closes should be a no-op, not an error. + proxy.close() class TestProxyFile(TestProxyFileBase): |