Lukáš, While reviewing your PR (mux-separation3), I came across the fact that the "parent" parameter of TreeNode doesn't do what *I* expected it to do. That is, the following test code fails:
import unittest from avocado.core import tree class ParentTest(unittest.TestCase): def test_parent_parameter(self): parent = tree.TreeNode(name='parent') child = tree.TreeNode(name='child', parent=parent) grandchild = tree.TreeNode(name='grandchild', parent=child) self.assertIn(child, parent.children) self.assertIn(grandchild, child.children) But it would work with this simple change: diff --git a/avocado/core/tree.py b/avocado/core/tree.py index 27d30f0..2fb3e11 100644 --- a/avocado/core/tree.py +++ b/avocado/core/tree.py @@ -69,6 +69,8 @@ class TreeNode(object): children = [] self.name = name self.value = value + if parent is not None: + parent.add_child(self) self.parent = parent self.children = [] self.ctrl = [] This is similar to what is already done with "children", and I have the feeling that both should behave similarly. Does it make sense? -- Cleber Rosa [ Sr Software Engineer - Virtualization Team - Red Hat ] [ Avocado Test Framework - avocado-framework.github.io ]
signature.asc
Description: OpenPGP digital signature