本文整理汇总了Python中lib.simple_config.SimpleConfig.set_key方法的典型用法代码示例。如果您正苦于以下问题:Python SimpleConfig.set_key方法的具体用法?Python SimpleConfig.set_key怎么用?Python SimpleConfig.set_key使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类lib.simple_config.SimpleConfig
的用法示例。
在下文中一共展示了SimpleConfig.set_key方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_can_set_options_set_in_user_config
# 需要导入模块: from lib.simple_config import SimpleConfig [as 别名]
# 或者: from lib.simple_config.SimpleConfig import set_key [as 别名]
def test_can_set_options_set_in_user_config(self):
another_path = tempfile.mkdtemp()
fake_read_user = lambda _: {"electrum_path": self.electrum_dir}
read_user_dir = lambda : self.user_dir
config = SimpleConfig(options={},
read_user_config_function=fake_read_user,
read_user_dir_function=read_user_dir)
config.set_key("electrum_path", another_path)
self.assertEqual(another_path, config.get("electrum_path"))
示例2: test_cannot_set_options_passed_by_command_line
# 需要导入模块: from lib.simple_config import SimpleConfig [as 别名]
# 或者: from lib.simple_config.SimpleConfig import set_key [as 别名]
def test_cannot_set_options_passed_by_command_line(self):
fake_read_user = lambda _: {"electrum_path": "b"}
read_user_dir = lambda : self.user_dir
config = SimpleConfig(options=self.options,
read_user_config_function=fake_read_user,
read_user_dir_function=read_user_dir)
config.set_key("electrum_path", "c")
self.assertEqual(self.options.get("electrum_path"),
config.get("electrum_path"))
示例3: test_can_set_options_from_system_config
# 需要导入模块: from lib.simple_config import SimpleConfig [as 别名]
# 或者: from lib.simple_config.SimpleConfig import set_key [as 别名]
def test_can_set_options_from_system_config(self):
fake_read_system = lambda : {"electrum_path": self.electrum_dir}
fake_read_user = lambda _: {}
read_user_dir = lambda : self.user_dir
config = SimpleConfig(options={},
read_system_config_function=fake_read_system,
read_user_config_function=fake_read_user,
read_user_dir_function=read_user_dir)
config.set_key("electrum_path", "c")
self.assertEqual("c", config.get("electrum_path"))
示例4: test_can_set_options_from_system_config_if_portable
# 需要导入模块: from lib.simple_config import SimpleConfig [as 别名]
# 或者: from lib.simple_config.SimpleConfig import set_key [as 别名]
def test_can_set_options_from_system_config_if_portable(self):
"""If the "portable" flag is set, the user can overwrite system
configuration options."""
another_path = tempfile.mkdtemp()
fake_read_system = lambda : {"electrum_path": self.electrum_dir}
fake_read_user = lambda _: {}
read_user_dir = lambda : self.user_dir
config = SimpleConfig(options={"portable": True},
read_system_config_function=fake_read_system,
read_user_config_function=fake_read_user,
read_user_dir_function=read_user_dir)
config.set_key("electrum_path", another_path)
self.assertEqual(another_path, config.get("electrum_path"))