forked from Textualize/textual
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a test for inheriting from a ListView
Added to test the fail in Textualize#1588. Any fix for this should cause this test to pass.
- Loading branch information
Showing
1 changed file
with
26 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
from textual.app import App, ComposeResult | ||
from textual.widgets import ListView, ListItem, Label | ||
|
||
|
||
class MyListView(ListView): | ||
def compose(self) -> ComposeResult: | ||
"""Compose the child widgets.""" | ||
for n in range(20): | ||
yield ListView(Label(f"This is item {n}")) | ||
|
||
|
||
class ListViewApp(App[None]): | ||
"""ListView test app.""" | ||
|
||
def compose(self) -> ComposeResult: | ||
"""Compose the child widgets.""" | ||
yield MyListView() | ||
|
||
|
||
async def test_inherited_list_view() -> None: | ||
"""A self-populating inherited ListView should work as normal.""" | ||
async with ListViewApp().run_test() as pilot: | ||
await pilot.press("tab") | ||
assert pilot.app.query_one(MyListView).index == 0 | ||
await pilot.press("down") | ||
assert pilot.app.query_one(MyListView).index == 1 |