mirror of
https://github.com/Textualize/textual.git
synced 2025-10-17 02:38:12 +03:00
Run black over recent Tree tests
Now that we're running black on tests...
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import pytest
|
||||
from textual.widgets import Tree, TreeNode
|
||||
|
||||
|
||||
def label_of(node: TreeNode[None]):
|
||||
"""Get the label of a node as a string"""
|
||||
return str(node.label)
|
||||
@@ -8,17 +9,21 @@ def label_of(node: TreeNode[None]):
|
||||
|
||||
def test_tree_node_children() -> None:
|
||||
"""A node's children property should act like an immutable list."""
|
||||
CHILDREN=23
|
||||
CHILDREN = 23
|
||||
tree = Tree[None]("Root")
|
||||
for child in range(CHILDREN):
|
||||
tree.root.add(str(child))
|
||||
assert len(tree.root.children)==CHILDREN
|
||||
assert len(tree.root.children) == CHILDREN
|
||||
for child in range(CHILDREN):
|
||||
assert label_of(tree.root.children[child]) == str(child)
|
||||
assert label_of(tree.root.children[0]) == "0"
|
||||
assert label_of(tree.root.children[-1]) == str(CHILDREN-1)
|
||||
assert [label_of(node) for node in tree.root.children] == [str(n) for n in range(CHILDREN)]
|
||||
assert [label_of(node) for node in tree.root.children[:2]] == [str(n) for n in range(2)]
|
||||
assert label_of(tree.root.children[-1]) == str(CHILDREN - 1)
|
||||
assert [label_of(node) for node in tree.root.children] == [
|
||||
str(n) for n in range(CHILDREN)
|
||||
]
|
||||
assert [label_of(node) for node in tree.root.children[:2]] == [
|
||||
str(n) for n in range(2)
|
||||
]
|
||||
with pytest.raises(TypeError):
|
||||
tree.root.children[0] = tree.root.children[1]
|
||||
with pytest.raises(TypeError):
|
||||
|
||||
Reference in New Issue
Block a user