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