summaryrefslogtreecommitdiff
path: root/Lib/test/test_mailbox.py
diff options
context:
space:
mode:
authorPetri Lehtinen <petri@digip.org>2012-06-29 15:12:54 +0300
committerPetri Lehtinen <petri@digip.org>2012-06-29 15:12:54 +0300
commit6646e362e5494f57e4490e58d0d43167b44c00f8 (patch)
treed3f08026ab87d8173db30cea534ab1e8346a7253 /Lib/test/test_mailbox.py
parentb09ea04cb31a454fda1acd06390ccb3c4a41d140 (diff)
parent74b2746acc7cb916b2aed7c2ee9b6150b571383b (diff)
downloadcpython-6646e362e5494f57e4490e58d0d43167b44c00f8.tar.gz
#5346: Preserve permissions of mbox, MMDF and Babyl mailbox files on flush()
Diffstat (limited to 'Lib/test/test_mailbox.py')
-rw-r--r--Lib/test/test_mailbox.py17
1 files changed, 17 insertions, 0 deletions
diff --git a/Lib/test/test_mailbox.py b/Lib/test/test_mailbox.py
index c56002bebf..52d2cd66e3 100644
--- a/Lib/test/test_mailbox.py
+++ b/Lib/test/test_mailbox.py
@@ -969,6 +969,23 @@ class _TestSingleFile(TestMailbox):
self._box = self._factory(self._path)
self.assertEqual(len(self._box), 1)
+ def test_permissions_after_flush(self):
+ # See issue #5346
+
+ # Make the mailbox world writable. It's unlikely that the new
+ # mailbox file would have these permissions after flush(),
+ # because umask usually prevents it.
+ mode = os.stat(self._path).st_mode | 0o666
+ os.chmod(self._path, mode)
+
+ self._box.add(self._template % 0)
+ i = self._box.add(self._template % 1)
+ # Need to remove one message to make flush() create a new file
+ self._box.remove(i)
+ self._box.flush()
+
+ self.assertEqual(os.stat(self._path).st_mode, mode)
+
class _TestMboxMMDF(_TestSingleFile):