示例#1
0
    def add_to_tar(self, tar, environment=None):
        if environment is None:
            environment = {}

        with hp.a_temp_directory() as command_root:
            self.do_copy(command_root, environment)
            self.do_modify(command_root, environment)
            self.do_command(command_root, environment)
            self.do_copy_into_tar(command_root, environment, tar)
示例#2
0
    def add_to_tar(self, tar, environment=None):
        if environment is None:
            environment = {}

        if self.temp_dir and not os.path.exists(self.temp_dir):
            os.makedirs(self.temp_dir)

        with hp.a_temp_directory(self.temp_dir) as command_root:
            self.do_copy(command_root, environment)
            self.do_modify(command_root, environment)
            self.do_command(command_root, environment)
            self.do_copy_into_tar(command_root, environment, tar)
示例#3
0
    def add_to_tar(self, tar, environment=None):
        if environment is None:
            environment = {}

        if self.temp_dir and not os.path.exists(self.temp_dir):
            os.makedirs(self.temp_dir)

        with hp.a_temp_directory(self.temp_dir) as command_root:
            self.do_copy(command_root, environment)
            self.do_modify(command_root, environment)
            self.do_command(command_root, environment)
            self.do_copy_into_tar(command_root, environment, tar)
示例#4
0
    it "yields the file object of a file that disappears after the context":
        with a_temp_file() as fle:
            assert os.path.exists(fle.name)
        assert not os.path.exists(fle.name)

    it "can write to the temporary file, close it and still read from it":
        with a_temp_file() as fle:
            fle.write("blah".encode("utf-8"))
            fle.close()
            with open(fle.name) as fread:
                self.assertEqual(fread.read(), "blah")
        assert not os.path.exists(fle.name)

describe BespinCase, "a_temp_directory":
    it "yields the name of a directory that disappears after the context":
        with a_temp_directory() as directory:
            assert os.path.exists(directory)
            assert os.path.isdir(directory)
        assert not os.path.exists(directory)

describe BespinCase, "until":

    @contextmanager
    def mock_log_and_time(self):
        """Mock out the log object and time, yield (log, time)"""
        fake_log = mock.Mock(name="log")
        fake_time = mock.Mock(name="time")
        with mock.patch("bespin.helpers.log", fake_log):
            with mock.patch("bespin.helpers.time", fake_time):
                yield (fake_log, fake_time)