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