本文整理匯總了Python中vital.ConfigBlock.get_value方法的典型用法代碼示例。如果您正苦於以下問題:Python ConfigBlock.get_value方法的具體用法?Python ConfigBlock.get_value怎麽用?Python ConfigBlock.get_value使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類vital.ConfigBlock
的用法示例。
在下文中一共展示了ConfigBlock.get_value方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: test_read_only
# 需要導入模塊: from vital import ConfigBlock [as 別名]
# 或者: from vital.ConfigBlock import get_value [as 別名]
def test_read_only(self):
cb = ConfigBlock()
cb.set_value('a', '1')
cb.mark_read_only('a')
nose.tools.assert_equal(cb.get_value('a'), '1')
cb.set_value('a', '2')
nose.tools.assert_equal(cb.get_value('a'), '1')
示例2: test_get_value
# 需要導入模塊: from vital import ConfigBlock [as 別名]
# 或者: from vital.ConfigBlock import get_value [as 別名]
def test_get_value(self):
cb = ConfigBlock()
cb.set_value('a', 'b')
cb.set_value('longer_value:foo', "BarBazThing")
nose.tools.assert_equal(cb.get_value('a'), 'b')
nose.tools.assert_equal(cb.get_value('longer_value:foo'),
'BarBazThing')
示例3: test_read_only
# 需要導入模塊: from vital import ConfigBlock [as 別名]
# 或者: from vital.ConfigBlock import get_value [as 別名]
def test_read_only(self):
cb = ConfigBlock()
cb.set_value('a', '1')
cb.mark_read_only('a')
nose.tools.assert_equal(cb.get_value('a'), '1')
nose.tools.assert_raises(
VitalConfigBlockReadOnlyException,
cb.set_value, 'a', '2'
)
nose.tools.assert_equal(cb.get_value('a'), '1')
示例4: test_subblock_view_nested
# 需要導入模塊: from vital import ConfigBlock [as 別名]
# 或者: from vital.ConfigBlock import get_value [as 別名]
def test_subblock_view_nested(self):
cb = ConfigBlock()
b_name = 'block'
o_name = 'other_block'
n_name = b_name + ConfigBlock.BLOCK_SEP + o_name
ka = 'ka'
kb = 'kb'
kc = 'kc'
va = 'va'
vb = 'vb'
vc = 'vc'
cb.set_value(n_name + ConfigBlock.BLOCK_SEP + ka, va)
cb.set_value(n_name + ConfigBlock.BLOCK_SEP + kb, vb)
cb.set_value(o_name + ConfigBlock.BLOCK_SEP + kc, vc)
sb = cb.subblock_view(n_name)
nose.tools.assert_true(sb.has_value(ka))
nose.tools.assert_false(sb.has_value(kc))
cb.set_value(n_name + ConfigBlock.BLOCK_SEP + ka, vb)
nose.tools.assert_equal(sb.get_value(ka), vb)
sb.set_value(ka, va)
nose.tools.assert_equal(cb.get_value(n_name + ConfigBlock.BLOCK_SEP + ka), va)
sb.unset_value(kb)
nose.tools.assert_false(cb.has_value(n_name + ConfigBlock.BLOCK_SEP + kb))
cb.set_value(n_name + ConfigBlock.BLOCK_SEP + kc, vc)
sb_keys = sb.available_keys()
nose.tools.assert_set_equal(set(sb_keys), {ka, kc})
示例5: test_read_only_unset
# 需要導入模塊: from vital import ConfigBlock [as 別名]
# 或者: from vital.ConfigBlock import get_value [as 別名]
def test_read_only_unset(self):
cb = ConfigBlock()
cb.set_value('a', '1')
cb.mark_read_only('a')
cb.unset_value('a')
nose.tools.assert_true(cb.has_value('a'))
nose.tools.assert_equal(cb.get_value('a'), '1')
示例6: test_merge_config
# 需要導入模塊: from vital import ConfigBlock [as 別名]
# 或者: from vital.ConfigBlock import get_value [as 別名]
def test_merge_config(self):
cb1 = ConfigBlock()
cb2 = ConfigBlock()
ka = 'ka'
kb = 'kb'
kc = 'kc'
va = 'va'
vb = 'vb'
vc = 'vc'
cb1.set_value(ka, va)
cb1.set_value(kb, va)
cb2.set_value(kb, vb)
cb2.set_value(kc, vc)
cb1.merge_config(cb2)
nose.tools.assert_equal(cb1.get_value(ka), va)
nose.tools.assert_equal(cb1.get_value(kb), vb)
nose.tools.assert_equal(cb1.get_value(kc), vc)
示例7: test_get_value_no_exist
# 需要導入模塊: from vital import ConfigBlock [as 別名]
# 或者: from vital.ConfigBlock import get_value [as 別名]
def test_get_value_no_exist(self):
cb = ConfigBlock()
k1 = 'a'
k2 = 'b'
v2 = '2'
nose.tools.assert_raises(
VitalConfigBlockNoSuchValueException,
cb.get_value, k1
)
nose.tools.assert_equal(cb.get_value(k2, v2), v2)
示例8: test_get_value_nested
# 需要導入模塊: from vital import ConfigBlock [as 別名]
# 或者: from vital.ConfigBlock import get_value [as 別名]
def test_get_value_nested(self):
cb = ConfigBlock()
k1 = 'a'
k2 = 'b'
v = 'c'
cb.set_value(k1 + ConfigBlock.BLOCK_SEP + k2, v)
nose.tools.assert_equal(cb.get_value(k1 + ConfigBlock.BLOCK_SEP + k2),
v)
sb = cb.subblock(k1)
nose.tools.assert_equal(sb.get_value(k2), v)
示例9: test_unset_value
# 需要導入模塊: from vital import ConfigBlock [as 別名]
# 或者: from vital.ConfigBlock import get_value [as 別名]
def test_unset_value(self):
cb = ConfigBlock()
cb.set_value('a', '1')
cb.set_value('b', '2')
cb.unset_value('a')
nose.tools.assert_false(cb.has_value('a'))
nose.tools.assert_raises(
VitalConfigBlockNoSuchValueException,
cb.get_value, 'a'
)
nose.tools.assert_equal(cb.get_value('b'), '2')
nose.tools.assert_true(cb.has_value('b'))