def set_config(self, section, option, value): """ Set a config option in a section and re-write the tahoe.cfg file :param str section: The name of the section in which to set the option. :param str option: The name of the option to set. :param str value: The value of the option. :raise UnescapedHashError: If the option holds a fURL and there is a ``#`` in the value. """ if option.endswith(".furl") and "#" in value: raise UnescapedHashError(section, option, value) copied_config = configutil.copy_config(self.config) configutil.set_config(copied_config, section, option, value) configutil.validate_config( self._config_fname, copied_config, self.valid_config_sections, ) if self.config_path is not None: configutil.write_config(self.config_path, copied_config) self.config = copied_config
def test_copy_config(self, cfgdict): """ ``copy_config`` creates a new ``ConfigParser`` object containing the same values as its input. """ cfg = to_configparser(cfgdict) copied = configutil.copy_config(cfg) # Should be equal self.assertEqual(cfg, copied) # But not because they're the same object. self.assertIsNot(cfg, copied)