| 1071 | self.assertEqual(len(self._box), 1) |
| 1072 | |
| 1073 | def test_permissions_after_flush(self): |
| 1074 | # See issue #5346 |
| 1075 | |
| 1076 | # Make the mailbox world writable. It's unlikely that the new |
| 1077 | # mailbox file would have these permissions after flush(), |
| 1078 | # because umask usually prevents it. |
| 1079 | mode = os.stat(self._path).st_mode | 0o666 |
| 1080 | os.chmod(self._path, mode) |
| 1081 | |
| 1082 | self._box.add(self._template % 0) |
| 1083 | i = self._box.add(self._template % 1) |
| 1084 | # Need to remove one message to make flush() create a new file |
| 1085 | self._box.remove(i) |
| 1086 | self._box.flush() |
| 1087 | |
| 1088 | self.assertEqual(os.stat(self._path).st_mode, mode) |
| 1089 | |
| 1090 | @requires_root_user |
| 1091 | @unittest.skipUnless(hasattr(os, 'chown'), 'requires os.chown') |