提交 63abc384 编写于 作者: L Lukáš Doktor

avocado.core.tree: Modify TreeNode.__eq__

Compare using whitelist instead of self.__dict__ + blacklist.
Signed-off-by: NLukáš Doktor <ldoktor@redhat.com>

Conflicts:
	avocado/core/tree.py
上级 efd7297a
......@@ -72,16 +72,15 @@ class TreeNode(object):
return self.iter_leaves()
def __eq__(self, other):
""" Compares node to other node or string to name of this node """
if isinstance(other, str): # Compare names
if self.name == other:
return True
elif isinstance(other, self.__class__):
first = self.__dict__.copy()
first.pop('parent')
second = other.__dict__.copy()
second.pop('parent')
return first == second
return False
else:
for attr in ('name', 'value', 'children'):
if getattr(self, attr) != getattr(other, attr):
return False
return True
def add_child(self, node):
if isinstance(node, self.__class__):
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册