Example #1
0
def print_tree(cur, start_node=None, indent='  ', _level=0):
    """
    Print tree to stdout.

    :param start_node: Starting point for tree output.
                       If ``None``, start at root node.
    :type start_node: int, Node, NodaData or None
    :param str indent: String to print per level (default: '  ')
    """
    if start_node is None:
        start_node = get_root_node(cur)

    print('{}{}'.format(indent*_level, start_node))  # noqa

    for child in list(get_children(cur, start_node)):
        print_tree(cur, child, indent=indent, _level=_level+1)
Example #2
0
def print_tree(cur, start_node=None, indent='  ', _level=0):
    """
    Print tree to stdout.

    :param start_node: Starting point for tree output.
                       If ``None``, start at root node.
    :type start_node: int, Node, NodaData or None
    :param str indent: String to print per level (default: '  ')
    """
    if start_node is None:
        start_node = get_root_node(cur)

    print('{}{}'.format(indent*_level, start_node))  # noqa

    for child in list(get_children(cur, start_node)):
        print_tree(cur, child, indent=indent, _level=_level+1)
def test_get_root_node(cur, root, nd1, nd2, nd2_1, nd2_1_1, nd3):
    root = get_root_node(cur)
    assert root.parent is None
def test_get_root_node_non_existing(cur):
    with pytest.raises(exceptions.NoRootNode):
        get_root_node(cur)
Example #5
0
def test_get_root_node_non_existing(cur):
    with pytest.raises(ValueError):
        get_root_node(cur)
Example #6
0
def test_get_root_node(cur, root, nd1, nd2, nd2_1, nd2_1_1, nd3):
    root = get_root_node(cur)
    assert root.parent is None
Example #7
0
def test_get_root_node_non_existing(cur):
    with pytest.raises(exceptions.NoRootNode):
        get_root_node(cur)
Example #8
0
def test_get_root_node_non_existing(cur):
    with pytest.raises(ValueError):
        get_root_node(cur)