| 1045 | '''Common tests for single-file mailboxes''' |
| 1046 | |
| 1047 | def test_add_doesnt_rewrite(self): |
| 1048 | # When only adding messages, flush() should not rewrite the |
| 1049 | # mailbox file. See issue #9559. |
| 1050 | |
| 1051 | # Inode number changes if the contents are written to another |
| 1052 | # file which is then renamed over the original file. So we |
| 1053 | # must check that the inode number doesn't change. |
| 1054 | inode_before = os.stat(self._path).st_ino |
| 1055 | |
| 1056 | self._box.add(self._template % 0) |
| 1057 | self._box.flush() |
| 1058 | |
| 1059 | inode_after = os.stat(self._path).st_ino |
| 1060 | self.assertEqual(inode_before, inode_after) |
| 1061 | |
| 1062 | # Make sure the message was really added |
| 1063 | self._box.close() |
| 1064 | self._box = self._factory(self._path) |
| 1065 | self.assertEqual(len(self._box), 1) |
| 1066 | |
| 1067 | def test_permissions_after_flush(self): |
| 1068 | # See issue #5346 |