本文整理匯總了Python中vital.ConfigBlock.subblock_view方法的典型用法代碼示例。如果您正苦於以下問題:Python ConfigBlock.subblock_view方法的具體用法?Python ConfigBlock.subblock_view怎麽用?Python ConfigBlock.subblock_view使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類vital.ConfigBlock
的用法示例。
在下文中一共展示了ConfigBlock.subblock_view方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: test_subblock_view_nested
# 需要導入模塊: from vital import ConfigBlock [as 別名]
# 或者: from vital.ConfigBlock import subblock_view [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})
示例2: test_subblock_view_match
# 需要導入模塊: from vital import ConfigBlock [as 別名]
# 或者: from vital.ConfigBlock import subblock_view [as 別名]
def test_subblock_view_match(self):
cb = ConfigBlock()
bname = 'block'
va = 'va'
cb.set_value(bname, va)
sb = cb.subblock_view(bname)
keys = sb.available_keys()
nose.tools.assert_equal(len(keys), 0)
示例3: test_subblock_view_prefix_match
# 需要導入模塊: from vital import ConfigBlock [as 別名]
# 或者: from vital.ConfigBlock import subblock_view [as 別名]
def test_subblock_view_prefix_match(self):
cb = ConfigBlock()
bname = 'block'
ka = 'ka'
va = 'va'
# intentionally not adding block separator
cb.set_value(bname + ka, va)
sb = cb.subblock_view(bname)
keys = sb.available_keys()
nose.tools.assert_equal(len(keys), 0)