(self)
| 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): |
nothing calls this directly
no test coverage detected