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

Method test_rmtree_with_dir_fd

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

Source from the content-addressed store, hash-verified

608
609 @unittest.skipUnless(shutil.rmtree.avoids_symlink_attacks, "dir_fd is not supported")
610 def test_rmtree_with_dir_fd(self):
611 tmp_dir = self.mkdtemp()
612 victim = 'killme'
613 fullname = os.path.join(tmp_dir, victim)
614 dir_fd = os.open(tmp_dir, os.O_RDONLY)
615 self.addCleanup(os.close, dir_fd)
616 os.mkdir(fullname)
617 os.mkdir(os.path.join(fullname, 'subdir'))
618 create_file(os.path.join(fullname, 'subdir', 'somefile'), 'foo')
619 self.assertTrue(os.path.exists(fullname))
620 shutil.rmtree(victim, dir_fd=dir_fd)
621 self.assertFalse(os.path.exists(fullname))
622
623 @unittest.skipIf(shutil.rmtree.avoids_symlink_attacks, "dir_fd is supported")
624 def test_rmtree_with_dir_fd_unsupported(self):

Callers

nothing calls this directly

Calls 9

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

Tested by

no test coverage detected