def test_rmtree_error(tmp_path): # Try to remove an inexistent directory testdir = tmp_path / 'tmp' testdir.mkdir() os.rmdir(str(testdir)) with pytest.raises(OSError): osext.rmtree(testdir)
def _makedir(self, *dirs, wipeout=False): ret = os.path.join(*dirs) if wipeout: osext.rmtree(ret, ignore_errors=True) os.makedirs(ret, exist_ok=True) return ret
def _rmtree(*args, **kwargs): osext.rmtree(testdir, *args, **kwargs) assert not os.path.exists(testdir)
def __exit__(self, exc_type, exc_val, exc_tb): osext.rmtree(self._workdir)