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

Method test_rmtree_works_on_symlinks

Lib/test/test_shutil.py:234–253  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

232
233 @os_helper.skip_unless_symlink
234 def test_rmtree_works_on_symlinks(self):
235 tmp = self.mkdtemp()
236 dir1 = os.path.join(tmp, 'dir1')
237 dir2 = os.path.join(dir1, 'dir2')
238 dir3 = os.path.join(tmp, 'dir3')
239 for d in dir1, dir2, dir3:
240 os.mkdir(d)
241 file1 = os.path.join(tmp, 'file1')
242 create_file(file1, 'foo')
243 link1 = os.path.join(dir1, 'link1')
244 os.symlink(dir2, link1)
245 link2 = os.path.join(dir1, 'link2')
246 os.symlink(dir3, link2)
247 link3 = os.path.join(dir1, 'link3')
248 os.symlink(file1, link3)
249 # make sure symlinks are removed but not followed
250 shutil.rmtree(dir1)
251 self.assertFalse(os.path.exists(dir1))
252 self.assertTrue(os.path.exists(dir3))
253 self.assertTrue(os.path.exists(file1))
254
255 @unittest.skipUnless(_winapi, 'only relevant on Windows')
256 def test_rmtree_fails_on_junctions_onerror(self):

Callers

nothing calls this directly

Calls 7

mkdtempMethod · 0.80
assertFalseMethod · 0.80
assertTrueMethod · 0.80
create_fileFunction · 0.70
joinMethod · 0.45
mkdirMethod · 0.45
existsMethod · 0.45

Tested by

no test coverage detected