mirror of
https://github.com/Textualize/textual.git
synced 2025-10-17 02:38:12 +03:00
Add an _index method to NodeList
This maps on to a normal List.index.
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
import pytest
|
||||
|
||||
from textual.widget import Widget
|
||||
from textual._node_list import NodeList
|
||||
|
||||
@@ -35,6 +37,15 @@ def test_contains():
|
||||
assert widget in nodes
|
||||
assert Widget() not in nodes
|
||||
|
||||
def test_index():
|
||||
"""Can we get the index of a widget in the list?"""
|
||||
widget = Widget()
|
||||
nodes = NodeList()
|
||||
with pytest.raises(ValueError):
|
||||
_ = nodes._index(widget)
|
||||
nodes._append(widget)
|
||||
assert nodes._index(widget) == 0
|
||||
|
||||
def test_remove():
|
||||
"""Can we remove a widget we've added?"""
|
||||
widget = Widget()
|
||||
|
||||
Reference in New Issue
Block a user