当前位置: 首页>>代码示例>>Python>>正文


Python Configuration.modify_existing_settings方法代码示例

本文整理汇总了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)
开发者ID:oscartap,项目名称:sudoku_project,代码行数:45,代码来源:test_configuration_class.py


注:本文中的configuration.Configuration.modify_existing_settings方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。