Example #1
0
def test_structural_copy_removes_leafless_branches(example_tree):
    example_tree.empty_branch = Tree(still_no_leaves = Tree())
    assert 'empty_branch' not in structural_copy(example_tree)
Example #2
0
def test_structural_copy_copies_branches_but_not_leaves(example_tree):
    result = structural_copy(example_tree)
    
    for path, value in walk(example_tree):
        assert get_at(result, path[:-1]) is not get_at(example_tree, path[:-1])
        assert get_at(result, path) is value
Example #3
0
def test_structural_copy_empty_tree():
    inpt = Tree()
    assert structural_copy(inpt) is not inpt