def test_rewrite_config(self): changes = [ ('renamed', 'renamed', 'choice'), ('moved', 'named', 'old', 'test'), ] read_old_config(self.cfg, changes, join(DATA, 'test.ini')) stream = StringIO() self.cfg.generate_config(stream) self.assertMultiLineEqual( stream.getvalue().strip(), """[TEST] dothis=yes value=' ' # you can also document the option multiple=yop # boom number=2 choice=yo multiple-choice=yo,ye named=key:val [AGROUP] diffgroup=pouet""")
def test_rewrite_config(self): changes = [('renamed', 'renamed', 'choice'), ('moved', 'named', 'old', 'test'), ] read_old_config(self.cfg, changes, 'data/test.ini') stream = StringIO() self.cfg.generate_config(stream) self.assertMultiLineEqual(stream.getvalue().strip(), """[TEST] dothis=yes value=' ' # you can also document the option multiple=yop # boom number=2 choice=yo multiple-choice=yo,ye named=key:val [AGROUP] diffgroup=pouet""")
def test_rewrite_config(self): changes = [("renamed", "renamed", "choice"), ("moved", "named", "old", "test")] read_old_config(self.cfg, changes, join(DATA, "test.ini")) stream = StringIO() self.cfg.generate_config(stream) self.assertMultiLineEqual( stream.getvalue().strip(), """[TEST] dothis=yes value=' ' # you can also document the option multiple=yop # boom number=2 choice=yo multiple-choice=yo,ye named=key:val [AGROUP] diffgroup=pouet""", )
def rewrite_configuration(self): configfile = self.config.main_config_file() if self._option_changes: read_old_config(self.config, self._option_changes, configfile) fd, newconfig = tempfile.mkstemp() for optdescr in self._option_changes: if optdescr[0] == 'added': optdict = self.config.get_option_def(optdescr[1]) if optdict.get('default') is REQUIRED: self.config.input_option(optdescr[1], optdict) self.config.generate_config(open(newconfig, 'w')) show_diffs(configfile, newconfig, askconfirm=self.confirm is not yes) os.close(fd) if exists(newconfig): os.unlink(newconfig)