def test_full_dir(self, path): path.mkdir() (path / 'child').touch() (path / 'subdir').mkdir() (path / 'subdir' / 'child child').touch() path_.remove(path) assert not path.exists()
def test_force(self, path): 'When force=True, remove file and directories even when read-only' path.mkdir() child = path / 'file' child.touch() child.chmod(0o000) path.chmod(0o000) path_.remove(path, force=True) assert not path.exists()
def test_symlink(self, path, symlink_to_file, symlink_in_dir): 'When path is symlink, remove symlink, but not its target' target_dir = Path('symlink_target') target_dir.mkdir() target_file = target_dir / 'file' target_file.touch() if symlink_in_dir: path.mkdir() source = path / 'source' else: source = path if symlink_to_file: source.symlink_to(target_file) else: source.symlink_to(target_dir) path_.remove(path) assert not path.exists() assert target_dir.exists() assert target_file.exists()
def test_empty_dir(self, path): path.mkdir() path_.remove(path) assert not path.exists()
def test_file(self, path): path.touch() path_.remove(path) assert not path.exists()
def test_missing(self, path): 'When remove missing, ignore' path_.remove(path)