本文整理汇总了Python中icarus.util.Tree.getval方法的典型用法代码示例。如果您正苦于以下问题:Python Tree.getval方法的具体用法?Python Tree.getval怎么用?Python Tree.getval使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类icarus.util.Tree
的用法示例。
在下文中一共展示了Tree.getval方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_getval_empty
# 需要导入模块: from icarus.util import Tree [as 别名]
# 或者: from icarus.util.Tree import getval [as 别名]
def test_getval_empty(self):
tree = Tree()
_ = tree[1][2][3]
self.assertIsNotNone(tree.getval([1]))
self.assertIsNotNone(tree.getval([1, 2]))
self.assertIsNone(tree.getval([1, 2, 3]))
self.assertIsNone(tree.getval([1, 2, 3, 4]))
示例2: test_nested_setitem
# 需要导入模块: from icarus.util import Tree [as 别名]
# 或者: from icarus.util.Tree import getval [as 别名]
def test_nested_setitem(self):
tree = Tree()
tree['a'] = {'b': {'c': 1}, 'd': 2}
self.assertIsInstance(tree, Tree)
self.assertIsInstance(tree['a'], Tree)
self.assertIsInstance(tree['a']['b'], Tree)
self.assertEqual(tree.getval(['a', 'b', 'c']), 1)
self.assertEqual(tree.getval(['a', 'd']), 2)
示例3: test_nested_update
# 需要导入模块: from icarus.util import Tree [as 别名]
# 或者: from icarus.util.Tree import getval [as 别名]
def test_nested_update(self):
tree = Tree()
tree['a'].update({'b': {'c': 1}, 'd': 2})
self.assertIsInstance(tree, Tree)
self.assertIsInstance(tree['a'], Tree)
self.assertIsInstance(tree['a']['b'], Tree)
self.assertEqual(tree.getval(['a', 'b', 'c']), 1)
self.assertEqual(tree.getval(['a', 'd']), 2)
示例4: test_init_from_nested_dict
# 需要导入模块: from icarus.util import Tree [as 别名]
# 或者: from icarus.util.Tree import getval [as 别名]
def test_init_from_nested_dict(self):
tree = Tree({'a': {'c': {'e': 1}}, 'b': {'d': 2}})
self.assertEqual(tree.getval(['a', 'c', 'e']), 1)
self.assertEqual(tree.getval(['b', 'd']), 2)
self.assertIsInstance(tree, Tree)
self.assertIsInstance(tree['a'], Tree)
self.assertIsInstance(tree['a']['c'], Tree)
self.assertIsInstance(tree.getval(['a', 'c']), Tree)
self.assertIsInstance(tree['b'], Tree)
示例5: test_update_new_brach
# 需要导入模块: from icarus.util import Tree [as 别名]
# 或者: from icarus.util.Tree import getval [as 别名]
def test_update_new_brach(self):
tree = Tree()
tree['a'].update({'b': 1, 'c': 2})
self.assertIsInstance(tree, Tree)
self.assertIsInstance(tree['a'], Tree)
self.assertEqual(tree.getval(['a', 'b']), 1)
self.assertEqual(tree.getval(['a', 'c']), 2)
示例6: test_update_base
# 需要导入模块: from icarus.util import Tree [as 别名]
# 或者: from icarus.util.Tree import getval [as 别名]
def test_update_base(self):
tree = Tree()
tree.update({'b': 1, 'c': 2})
self.assertIsInstance(tree, Tree)
self.assertEqual(tree.getval(['b']), 1)
self.assertEqual(tree.getval(['c']), 2)
示例7: test_init_from_dict_kwargs
# 需要导入模块: from icarus.util import Tree [as 别名]
# 或者: from icarus.util.Tree import getval [as 别名]
def test_init_from_dict_kwargs(self):
tree = Tree({'c': 3}, a=1, b=2)
self.assertEqual(tree.getval(['a']), 1)
self.assertEqual(tree.getval(['b']), 2)
self.assertEqual(tree.getval(['c']), 3)
self.assertIsInstance(tree, Tree)
示例8: test_init_from_nested_kwargs
# 需要导入模块: from icarus.util import Tree [as 别名]
# 或者: from icarus.util.Tree import getval [as 别名]
def test_init_from_nested_kwargs(self):
tree = Tree(a=1, b=dict(c=2))
self.assertEqual(tree.getval(['a']), 1)
self.assertEqual(tree.getval(['b', 'c']), 2)
self.assertIsInstance(tree, Tree)
self.assertIsInstance(tree['b'], Tree)
示例9: test_init_from_dict
# 需要导入模块: from icarus.util import Tree [as 别名]
# 或者: from icarus.util.Tree import getval [as 别名]
def test_init_from_dict(self):
tree = Tree({'a': 1, 'b': 2})
self.assertEqual(tree.getval(['a']), 1)
self.assertEqual(tree.getval(['b']), 2)
self.assertIsInstance(tree, Tree)
示例10: test_getval_none
# 需要导入模块: from icarus.util import Tree [as 别名]
# 或者: from icarus.util.Tree import getval [as 别名]
def test_getval_none(self):
tree = Tree()
self.assertIsNone(tree.getval([1]))
self.assertIsNone(tree.getval([1, 2]))
self.assertIsNone(tree.getval([3, 4, 5]))
示例11: test_getval
# 需要导入模块: from icarus.util import Tree [as 别名]
# 或者: from icarus.util.Tree import getval [as 别名]
def test_getval(self):
tree = Tree()
tree[1][2][3] = 4
self.assertEqual(tree.getval([1, 2, 3]), 4)
self.assertEqual(tree.getval([1, 2])[3], 4)
self.assertEqual(tree.getval([1])[2][3], 4)
示例12: test_getset
# 需要导入模块: from icarus.util import Tree [as 别名]
# 或者: from icarus.util.Tree import getval [as 别名]
def test_getset(self):
tree = Tree()
tree.setval([1, 2, 3, 4], 5)
self.assertEqual(tree.getval([1, 2, 3, 4]), 5)