mirror of
https://github.com/Textualize/textual.git
synced 2025-10-17 02:38:12 +03:00
There's going to be a whole bunch of tests relating to the Tree and TreeNode coming, let's make sure this ends up being fairly granular. (side thought: it might be a good time soon to revisit all the tests for Textual and try and wrangle them into some tidy structure)
18 lines
703 B
Python
18 lines
703 B
Python
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")
|