diff options
author | Petri Lehtinen <petri@digip.org> | 2012-06-29 12:12:54 (GMT) |
---|---|---|
committer | Petri Lehtinen <petri@digip.org> | 2012-06-29 12:12:54 (GMT) |
commit | 25652884b452142460f5868ac28af4f12895e046 (patch) | |
tree | 51d38f09fcbb7fad851a15383a6ca7e522c0e293 /Lib/test/test_mailbox.py | |
parent | 31a78c3d6521272c418f5ffbb8824d26be40db50 (diff) | |
parent | 5b5619f717be2a712c05d6c63a0ca4184f263aee (diff) | |
download | cpython-25652884b452142460f5868ac28af4f12895e046.zip cpython-25652884b452142460f5868ac28af4f12895e046.tar.gz cpython-25652884b452142460f5868ac28af4f12895e046.tar.bz2 |
#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.py | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/Lib/test/test_mailbox.py b/Lib/test/test_mailbox.py index c56002b..52d2cd6 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): |