forked from Textualize/textual
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a public read-only parent property to TreeNode
See Textualize#1397.
- Loading branch information
Showing
3 changed files
with
23 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |