MCPcopy Index your code
hub / github.com/RustPython/RustPython / test_ownership_after_flush

Method test_ownership_after_flush

Lib/test/test_mailbox.py:1085–1123  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

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
1126class _TestMboxMMDF(_TestSingleFile):

Callers

nothing calls this directly

Calls 9

skipTestMethod · 0.80
chownMethod · 0.80
import_moduleMethod · 0.45
statMethod · 0.45
chmodMethod · 0.45
addMethod · 0.45
removeMethod · 0.45
flushMethod · 0.45
assertEqualMethod · 0.45

Tested by

no test coverage detected