def test_cant_add_named_node_as_member_of_itself(self):
     # TO-DO Validation logic to spot larger graph cycles
     node1 = TreeNamedNode('foo')
     with pytest.raises(TreeNodeError) as exc_info:
         node1.add_member(node1)
     assert exc_info.value.message == \
         'Node "foo" can\'t have itself as a member'
 def test_try_to_add_comment_to_named_node(self):
     node1 = TreeNamedNode('foo')
     node2 = TreeCommentString("# Another perceptive comment")
     with pytest.raises(TreeNodeError) as exc_info:
         node1.add_member(node2)
     assert "can't be a member" in exc_info.value.message
 def test_add_member_to_named_node(self):
     node1 = TreeNamedNode('foo')
     node2 = TreeNamedNode('bar')
     node1.add_member(node2)
     assert len(node1.members) == 1
     assert node1.members[0] == node2