def test_remove_file_again(): directory = pathutils.tempdir() fileobj = directory.joinpath("file") fileobj.write_text("hello") pathutils.remove(fileobj) pathutils.remove(fileobj)
def test_remove_file_str(): directory = pathutils.tempdir() fileobj = directory.joinpath("file") fileobj.write_text("hello") pathutils.remove(str(fileobj)) assert not fileobj.exists() assert directory.exists() pathutils.remove(directory)
def test_tempdir(): directory = pathutils.tempdir() assert isinstance(directory, pathlib.Path) assert directory.is_dir() dir2 = pathutils.tempdir() assert directory != dir2 pathutils.remove(directory) pathutils.remove(dir2)
def on_post_execute(self, task, exc_value, exc_type, exc_tb): try: if exc_value: LOG.info("Do not execute anything because of %s: %s", exc_type, exc_value) return files = list(self.tempdir.iterdir()) if len(files) != 1: raise RuntimeError( "One file has to be present in temporary directory. " "Found: {0!r}".format(files)) return self.create_server(task, json.loads(files[0].read_text())) finally: pathutils.remove(self.tempdir)
def test_remove_dir_str(): directory = pathutils.tempdir() pathutils.remove(str(directory)) assert not directory.exists()
def test_nothing_to_remove(): pathutils.remove(None)
def on_post_execute(self, task, exc_value, exc_type, exc_tb): pathutils.remove(self.fetchdir) super().on_post_execute(task, exc_value, exc_type, exc_tb)