Esempio n. 1
0
def test_remove_file_again():
    directory = pathutils.tempdir()
    fileobj = directory.joinpath("file")
    fileobj.write_text("hello")

    pathutils.remove(fileobj)
    pathutils.remove(fileobj)
Esempio n. 2
0
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)
Esempio n. 3
0
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)
Esempio n. 4
0
    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)
Esempio n. 5
0
def test_remove_dir_str():
    directory = pathutils.tempdir()
    pathutils.remove(str(directory))

    assert not directory.exists()
Esempio n. 6
0
def test_nothing_to_remove():
    pathutils.remove(None)
Esempio n. 7
0
 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)
Esempio n. 8
0
 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)