mirror of
https://github.com/Textualize/textual.git
synced 2025-10-17 02:38:12 +03:00
Merge branch 'main' into tree-node-children-prop
This commit is contained in:
@@ -2,13 +2,8 @@ import pytest
|
||||
from textual.widgets import Tree, TreeNode
|
||||
|
||||
def label_of(node: TreeNode[None]):
|
||||
"""Get the label of a node.
|
||||
|
||||
TODO: This is just a helper function to reduce the number of type
|
||||
errors, which can and will be remove once this code is merged with a
|
||||
version of main that also has the TreeNode.label PR merged.
|
||||
"""
|
||||
return str(node._label)
|
||||
"""Get the label of a node as a string"""
|
||||
return str(node.label)
|
||||
|
||||
|
||||
def test_tree_node_children() -> None:
|
||||
|
||||
17
tests/tree/test_tree_node_label.py
Normal file
17
tests/tree/test_tree_node_label.py
Normal file
@@ -0,0 +1,17 @@
|
||||
from textual.widgets import Tree, TreeNode
|
||||
from rich.text import Text
|
||||
|
||||
def test_tree_node_label() -> None:
|
||||
"""It should be possible to modify a TreeNode's label."""
|
||||
node = TreeNode(Tree[None]("Xenomorph Lifecycle"), None, 0, "Facehugger")
|
||||
assert node.label == Text("Facehugger")
|
||||
node.label = "Chestbuster"
|
||||
assert node.label == Text("Chestbuster")
|
||||
|
||||
def test_tree_node_label_via_tree() -> None:
|
||||
"""It should be possible to modify a TreeNode's label when created via a Tree."""
|
||||
tree = Tree[None]("Xenomorph Lifecycle")
|
||||
node = tree.root.add("Facehugger")
|
||||
assert node.label == Text("Facehugger")
|
||||
node.label = "Chestbuster"
|
||||
assert node.label == Text("Chestbuster")
|
||||
Reference in New Issue
Block a user