Beispiel #1
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
Beispiel #2
0
def test_get_at_can_get_a_leaf(example_tree):
    assert get_at(example_tree, ('foo', 'bar', 'baz')) == sentinel.foobarbaz
Beispiel #3
0
def test_get_at_non_existent_path(example_tree):
    with pytest.raises(AttributeError):
        get_at(example_tree, ('does', 'not', 'exist'))
Beispiel #4
0
def test_get_at_empty_path_in_empty_tree():
    assert get_at(Tree(), []) == Tree()
Beispiel #5
0
def test_get_at_empty_path(example_tree):
    assert get_at(example_tree, []) == example_tree
Beispiel #6
0
def test_get_at_can_get_a_subtree(example_tree):
    assert get_at(example_tree, ('foo', 'bar')) == example_tree.foo.bar