MCPcopy Index your code
hub / github.com/python/cpython / test_delete_unwritable

Method test_delete_unwritable

Lib/test/test_pathlib/test_pathlib.py:2170–2191  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

2168 @os_helper.skip_if_dac_override
2169 @os_helper.skip_unless_working_chmod
2170 def test_delete_unwritable(self):
2171 tmp = self.cls(self.base, 'delete')
2172 tmp.mkdir()
2173 child_file_path = tmp / 'a'
2174 child_dir_path = tmp / 'b'
2175 child_file_path.write_text("")
2176 child_dir_path.mkdir()
2177 old_dir_mode = tmp.stat().st_mode
2178 old_child_file_mode = child_file_path.stat().st_mode
2179 old_child_dir_mode = child_dir_path.stat().st_mode
2180 # Make unwritable.
2181 new_mode = stat.S_IREAD | stat.S_IEXEC
2182 try:
2183 child_file_path.chmod(new_mode)
2184 child_dir_path.chmod(new_mode)
2185 tmp.chmod(new_mode)
2186
2187 self.assertRaises(PermissionError, tmp._delete)
2188 finally:
2189 tmp.chmod(old_dir_mode)
2190 child_file_path.chmod(old_child_file_mode)
2191 child_dir_path.chmod(old_child_dir_mode)
2192
2193 @needs_windows
2194 def test_delete_inner_junction(self):

Callers

nothing calls this directly

Calls 6

clsMethod · 0.45
mkdirMethod · 0.45
write_textMethod · 0.45
statMethod · 0.45
chmodMethod · 0.45
assertRaisesMethod · 0.45

Tested by

no test coverage detected