def test_reading_generated_file(self): dump = self.config.dump() re_init_config = BootConfigParser(dump) re_init_dump = re_init_config.dump() self.assertEqual(dump.splitlines(), re_init_dump.splitlines())
def set_value(self, name, value=None, config_filter=Filter.ALL): # if the value argument is None, the option will be commented out lines = read_file_contents_as_lines(self.path) if not lines: # this is true if the file is empty, not sure that was intended. return logger.info('writing value to {} {} {}'.format(self.path, name, value)) config = BootConfigParser(lines) config.set(name, value, config_filter=config_filter) with open_locked(self.path, "w") as boot_config_file: boot_config_file.write(config.dump()) # flush changes to disk boot_config_file.flush() os.fsync(boot_config_file.fileno())
def test_list_init(self): test = BootConfigParser(self.base_config.splitlines()) self.compare_config_dumps(self.base_config, test.dump())