Add a public read-only parent property to TreeNode

See #1397.
This commit is contained in:
Dave Pearson
2023-01-05 10:35:25 +00:00
committed by Rodrigo Girão Serrão
parent 2867b09923
commit af56d88a6d
3 changed files with 16 additions and 0 deletions

View File

@@ -0,0 +1,10 @@
from textual.widgets import TreeNode, Tree
def test_tree_node_parent() -> None:
"""It should be possible to access a TreeNode's parent."""
tree = Tree[None]("Anakin")
child = tree.root.add("Leia")
grandchild = child.add("Ben")
assert tree.root.parent is None
assert grandchild.parent == child
assert child.parent == tree.root