(self)
| 1083 | |
| 1084 | @unittest.skipUnless(hasattr(os, 'chown'), 'requires os.chown') |
| 1085 | def test_ownership_after_flush(self): |
| 1086 | # See issue gh-117467 |
| 1087 | |
| 1088 | pwd = import_helper.import_module('pwd') |
| 1089 | grp = import_helper.import_module('grp') |
| 1090 | st = os.stat(self._path) |
| 1091 | |
| 1092 | for e in pwd.getpwall(): |
| 1093 | if e.pw_uid != st.st_uid: |
| 1094 | other_uid = e.pw_uid |
| 1095 | break |
| 1096 | else: |
| 1097 | self.skipTest("test needs more than one user") |
| 1098 | |
| 1099 | for e in grp.getgrall(): |
| 1100 | if e.gr_gid != st.st_gid: |
| 1101 | other_gid = e.gr_gid |
| 1102 | break |
| 1103 | else: |
| 1104 | self.skipTest("test needs more than one group") |
| 1105 | |
| 1106 | try: |
| 1107 | os.chown(self._path, other_uid, other_gid) |
| 1108 | except OSError: |
| 1109 | self.skipTest('test needs root privilege') |
| 1110 | # Change permissions as in test_permissions_after_flush. |
| 1111 | mode = st.st_mode | 0o666 |
| 1112 | os.chmod(self._path, mode) |
| 1113 | |
| 1114 | self._box.add(self._template % 0) |
| 1115 | i = self._box.add(self._template % 1) |
| 1116 | # Need to remove one message to make flush() create a new file |
| 1117 | self._box.remove(i) |
| 1118 | self._box.flush() |
| 1119 | |
| 1120 | st = os.stat(self._path) |
| 1121 | self.assertEqual(st.st_uid, other_uid) |
| 1122 | self.assertEqual(st.st_gid, other_gid) |
| 1123 | self.assertEqual(st.st_mode, mode) |
| 1124 | |
| 1125 | |
| 1126 | class _TestMboxMMDF(_TestSingleFile): |
nothing calls this directly
no test coverage detected