本文整理汇总了Python中configuration.Configuration.modify_existing_settings方法的典型用法代码示例。如果您正苦于以下问题:Python Configuration.modify_existing_settings方法的具体用法?Python Configuration.modify_existing_settings怎么用?Python Configuration.modify_existing_settings使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类configuration.Configuration
的用法示例。
在下文中一共展示了Configuration.modify_existing_settings方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: TestConfigurationClassAndMethods
# 需要导入模块: from configuration import Configuration [as 别名]
# 或者: from configuration.Configuration import modify_existing_settings [as 别名]
class TestConfigurationClassAndMethods(unittest.TestCase):
def setUp(self):
self.file_name = "config.ini"
#default settings of configuration file
self.settings01 = {'Output_file':'Txt', 'Default_alghoritm':'Norvig', 'Dificult_level':'Easier'}
self.config01 = Configuration("config.ini", self.settings01)
self.settings02 = {'Output_file':'csv', 'Default_alghoritm':'Norvig', 'Dificult_level':'Easier'}
self.config02 = Configuration("config.ini", self.settings02)
self.settings03 = {'Output_file':'txt', 'Default_alghoritm':'Backtracking', 'Dificult_level':'Dificult'}
self.config03 = Configuration("config.ini", self.settings03)
self.settings04 = {'Output_file':'txt', 'Default_alghoritm':'Backtracking', 'Dificult_level':'Dificult','CustomX':'ValueX'}
self.config04 = Configuration("config.ini", self.settings03)
def test_configuration_file_has_Default_values(self):
configsetting = self.config01.leave_default_value()
self.assertEqual(self.settings01, configsetting)
def test_an_existing_setting_is_properly_modified(self):
configsetting = self.config02.modify_existing_settings("Output_file", "csv")
self.assertEqual(self.config02.settings, configsetting)
def test_all_existing_settings_are_modified(self):
configsetting = Configuration("config.ini", self.settings03)
self.assertEqual(self.settings03, configsetting.settings)
def test_all_existing_settings_are_left_by_default(self):
self.assertEqual(self.settings01, self.config01.leave_default_value())
def test_that_a_new_setting_is_added_to_setting_list(self):
new_parameter = self.config04.add_new_custom_setting("CustomX", "ValueX")
self.assertEqual(self.settings04, new_parameter)
def test_no_changes_is_made_when_not_existent_seeting_is_being_modified(self):
configsetting = self.config02.modify_existing_settings("Output_fileX", "csv")
self.assertNotEqual(configsetting, self.config02.settings)
def test_that_when_custom_setting_value_is_empty_the_default_setting_remain_active(self):
configsetting = self.config02.modify_existing_settings(" ", "csv")
self.assertEqual(configsetting, self.config02.settings)