summaryrefslogtreecommitdiffstats
path: root/Lib/test
diff options
context:
space:
mode:
authorR David Murray <rdmurray@bitdance.com>2011-06-18 02:24:05 (GMT)
committerR David Murray <rdmurray@bitdance.com>2011-06-18 02:24:05 (GMT)
commitc88bce1580c61ee33bf72e55b817940dba46d99c (patch)
treeb2326ab96c8d50fda11c4db71e1827cc3c9ccfa9 /Lib/test
parent05ff9904010a488cc640637ac8255cae41b270dd (diff)
downloadcpython-c88bce1580c61ee33bf72e55b817940dba46d99c.zip
cpython-c88bce1580c61ee33bf72e55b817940dba46d99c.tar.gz
cpython-c88bce1580c61ee33bf72e55b817940dba46d99c.tar.bz2
#11700: proxy object close methods can now be called multiple times
This makes them work like the close provided by regular file objects.
Diffstat (limited to 'Lib/test')
-rw-r--r--Lib/test/test_mailbox.py13
1 files changed, 12 insertions, 1 deletions
diff --git a/Lib/test/test_mailbox.py b/Lib/test/test_mailbox.py
index 10317c3..fb4812d 100644
--- a/Lib/test/test_mailbox.py
+++ b/Lib/test/test_mailbox.py
@@ -297,6 +297,13 @@ class TestMailbox(TestBase):
self.assertEqual(data1.decode('ascii').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.keys, do_keys=True, do_values=False)
@@ -1862,8 +1869,12 @@ class TestProxyFileBase(TestBase):
def _test_close(self, proxy):
# Close a file
+ self.assertFalse(proxy.closed)
+ proxy.close()
+ self.assertTrue(proxy.closed)
+ # Issue 11700 subsequent closes should be a no-op.
proxy.close()
- self.assertRaises(AttributeError, lambda: proxy.close())
+ self.assertTrue(proxy.closed)
class TestProxyFile(TestProxyFileBase):