Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TST: TreeObject.remove_child for middle node #1235

Merged
merged 1 commit into from Aug 14, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
21 changes: 19 additions & 2 deletions tests/test_generic.py
Expand Up @@ -458,21 +458,38 @@ def test_remove_child_found_in_tree():
tree.add_child(child2_ref, writer)
assert tree[NameObject("/Count")] == 2

# Remove child
# Remove last child
tree.remove_child(child2)
assert tree[NameObject("/Count")] == 1

# Add new child
child3 = TreeObject()
child3[NameObject("/Foo")] = TextStringObject("3")
child3_ref = writer._add_object(child3)
tree.add_child(child3_ref, writer)
assert tree[NameObject("/Count")] == 2

# Remove child
# Remove first child
child1 = tree[NameObject("/First")]
tree.remove_child(child1)
assert tree[NameObject("/Count")] == 1

child4 = TreeObject()
child4[NameObject("/Foo")] = TextStringObject("4")
child4_ref = writer._add_object(child4)
tree.add_child(child4_ref, writer)
assert tree[NameObject("/Count")] == 2

child5 = TreeObject()
child5[NameObject("/Foo")] = TextStringObject("5")
child5_ref = writer._add_object(child5)
tree.add_child(child5_ref, writer)
assert tree[NameObject("/Count")] == 3

# Remove middle child
tree.remove_child(child4)
assert tree[NameObject("/Count")] == 2


def test_remove_child_in_tree():
pdf = RESOURCE_ROOT / "form.pdf"
Expand Down