File: test_tree_node_label.py

package info (click to toggle)
textual 2.1.2-1.1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 55,080 kB
  • sloc: python: 85,423; lisp: 1,669; makefile: 101
file content (21 lines) | stat: -rw-r--r-- 738 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
from rich.text import Text

from textual.widgets import Tree
from textual.widgets.tree import TreeNode


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")