本文整理匯總了Python中rubick.config_model.Configuration.set方法的典型用法代碼示例。如果您正苦於以下問題:Python Configuration.set方法的具體用法?Python Configuration.set怎麽用?Python Configuration.set使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類rubick.config_model.Configuration
的用法示例。
在下文中一共展示了Configuration.set方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: test_contains
# 需要導入模塊: from rubick.config_model import Configuration [as 別名]
# 或者: from rubick.config_model.Configuration import set [as 別名]
def test_contains(self):
c = Configuration()
self.assertFalse(self.section in c)
c.set(self.fullparam, self.value)
self.assertTrue(self.section in c)
示例2: test_parameter_names_containing_sections
# 需要導入模塊: from rubick.config_model import Configuration [as 別名]
# 或者: from rubick.config_model.Configuration import set [as 別名]
def test_parameter_names_containing_sections(self):
c = Configuration()
c.set(self.fullparam, self.value)
self.assertEqual(
self.value, c.get('%s.%s' %
(self.section, self.param)))
示例3: test_cycle_template_substitution_resolves_in_empty_string
# 需要導入模塊: from rubick.config_model import Configuration [as 別名]
# 或者: from rubick.config_model.Configuration import set [as 別名]
def test_cycle_template_substitution_resolves_in_empty_string(self):
c = Configuration()
c.set('a', 'a$c')
c.set('b', 'b$a')
c.set('c', 'c$b')
self.assertEqual('cba', c.get('c'))
示例4: test_getting_raw_values
# 需要導入模塊: from rubick.config_model import Configuration [as 別名]
# 或者: from rubick.config_model.Configuration import set [as 別名]
def test_getting_raw_values(self):
c = Configuration()
c.set('a', '$b')
c.set('b', 'x')
self.assertEqual('$b', c.get('a', raw=True))
示例5: test_subsection_keys
# 需要導入模塊: from rubick.config_model import Configuration [as 別名]
# 或者: from rubick.config_model.Configuration import set [as 別名]
def test_subsection_keys(self):
c = Configuration()
c.set_default('%s.param1' % self.section, '123')
c.set('%s.param2' % self.section, '456')
self.assertEqual(
['param1', 'param2'], sorted(c.section(self.section).keys()))
示例6: test_template_substitution
# 需要導入模塊: from rubick.config_model import Configuration [as 別名]
# 或者: from rubick.config_model.Configuration import set [as 別名]
def test_template_substitution(self):
c = Configuration()
c.set('a', 'x')
c.set('b', '$a')
c.set('c', '$b')
self.assertEqual('x', c.get('c'))
示例7: test_subsection_getitem
# 需要導入模塊: from rubick.config_model import Configuration [as 別名]
# 或者: from rubick.config_model.Configuration import set [as 別名]
def test_subsection_getitem(self):
c = Configuration()
c.set(self.fullparam, self.value)
cs = c.section(self.section)
self.assertEqual(self.value, cs[self.param])
示例8: test_type_for_unknown_param
# 需要導入模塊: from rubick.config_model import Configuration [as 別名]
# 或者: from rubick.config_model.Configuration import set [as 別名]
def test_type_for_unknown_param(self):
schema = ConfigSchema('test', '1.0', 'ini', [])
c = Configuration(schema)
c.set('param1', '123')
self.assertEqual('123', c.get('param1'))
示例9: test_subsection_items
# 需要導入模塊: from rubick.config_model import Configuration [as 別名]
# 或者: from rubick.config_model.Configuration import set [as 別名]
def test_subsection_items(self):
c = Configuration()
c.set('%s.param1' % self.section, 'value1')
c.set_default('%s.param2' % self.section, 'value2')
self.assertEqual(
[('param1', 'value1'), ('param2', 'value2')],
sorted(c.section(self.section).items()))
示例10: test_validate_returns_none_for_unknown_param
# 需要導入模塊: from rubick.config_model import Configuration [as 別名]
# 或者: from rubick.config_model.Configuration import set [as 別名]
def test_validate_returns_none_for_unknown_param(self):
schema = ConfigSchema('test', '1.0', 'ini', [])
c = Configuration(schema)
c.set('param1', '123')
self.assertIsNone(c.validate('param1'))
示例11: test_subsection_contains
# 需要導入模塊: from rubick.config_model import Configuration [as 別名]
# 或者: from rubick.config_model.Configuration import set [as 別名]
def test_subsection_contains(self):
c = Configuration()
c.set('section1.param1', '123')
c.set_default('section2.param2', '234')
self.assertTrue('param1' in c.section('section1'))
self.assertTrue('param2' in c.section('section2'))
self.assertFalse('param1' in c.section('section2'))
示例12: test_validate_returns_error_if_valid_is_invalid
# 需要導入模塊: from rubick.config_model import Configuration [as 別名]
# 或者: from rubick.config_model.Configuration import set [as 別名]
def test_validate_returns_error_if_valid_is_invalid(self):
schema = ConfigSchema('test', '1.0', 'ini', [
ConfigParameterSchema('param1', type='integer', section='DEFAULT')
])
c = Configuration(schema)
c.set('param1', 'abc')
self.assertTrue(isinstance(c.validate('param1'), InvalidValueError))
示例13: test_validate_returns_none_if_value_is_valid
# 需要導入模塊: from rubick.config_model import Configuration [as 別名]
# 或者: from rubick.config_model.Configuration import set [as 別名]
def test_validate_returns_none_if_value_is_valid(self):
schema = ConfigSchema('test', '1.0', 'ini', [
ConfigParameterSchema('param1', type='integer', section='DEFAULT')
])
c = Configuration(schema)
c.set('param1', '123')
self.assertIsNone(c.validate('param1'))
示例14: test_getting_typed_param_raw_value
# 需要導入模塊: from rubick.config_model import Configuration [as 別名]
# 或者: from rubick.config_model.Configuration import set [as 別名]
def test_getting_typed_param_raw_value(self):
schema = ConfigSchema('test', '1.0', 'ini', [
ConfigParameterSchema('param1', type='integer', section='DEFAULT')
])
c = Configuration(schema)
c.set('param1', '123')
self.assertEqual('123', c.get('param1', raw=True))
示例15: test_typed_param_with_invalid_value_returns_string_value
# 需要導入模塊: from rubick.config_model import Configuration [as 別名]
# 或者: from rubick.config_model.Configuration import set [as 別名]
def test_typed_param_with_invalid_value_returns_string_value(self):
schema = ConfigSchema('test', '1.0', 'ini', [
ConfigParameterSchema('param1', type='integer', section='DEFAULT')
])
c = Configuration(schema)
c.set('param1', '123a')
self.assertEqual('123a', c.get('param1'))