def test_del_at_non_existent_path(example_tree): with pytest.raises(AttributeError): del_at(example_tree, ('does', 'not', 'exist'))
def test_del_at_non_existent_leaf(example_tree): with pytest.raises(AttributeError): del_at(example_tree, ('foo', 'bar', 'new_node'))
def test_del_at_empty_path(example_tree): with pytest.raises(ValueError): del_at(example_tree, [])
def test_del_at_empty_path_in_empty_tree(): with pytest.raises(ValueError): del_at(Tree(), [])
def test_del_at_can_remove_a_subtree(example_tree): pre_exisiting_paths = {path for path, _ in walk(example_tree)} del_at(example_tree, ('foo', 'bar')) assert {path for path, _ in walk(example_tree)} == pre_exisiting_paths - {('foo', 'bar', 'baz'), ('foo', 'bar', 'bang')}