def test_remove_node_from_document(): '''Remove a node from the document.''' document = Document() document.add(Node('root')) node, = document.roots document.remove(node) assert node not in document.roots
def test_remove_subtree_from_document(): '''Remove a subtree from the document.''' document = Document() root = Node('root') node = Node('node') root.children.append(node) document.add(root) document.save() assert root in document.roots assert node in root.children document.remove(root) document.save() assert root not in document.roots assert node in root.children
def test_add_and_remove_child_node(): '''Add and remove a child node.''' document = Document() root = Node('root') node = Node('node') document.add(root) document.add(node) assert node in document.roots assert node not in root.children root.children.append(node) assert node not in document.roots assert node in root.children del root.children[0] assert node in document.roots assert node not in root.children document.remove(node) assert node not in document.roots assert node not in root.children