mirror of
https://github.com/Textualize/textual.git
synced 2025-10-17 02:38:12 +03:00
Run black over widget removing tests
This commit is contained in:
@@ -4,6 +4,7 @@ from textual.widget import Widget
|
||||
from textual.widgets import Static, Button
|
||||
from textual.containers import Container
|
||||
|
||||
|
||||
async def test_remove_single_widget():
|
||||
"""It should be possible to the only widget on a screen."""
|
||||
async with App().run_test() as pilot:
|
||||
@@ -12,6 +13,7 @@ async def test_remove_single_widget():
|
||||
await pilot.app.query_one(Static).remove()
|
||||
assert len(pilot.app.screen.children) == 0
|
||||
|
||||
|
||||
async def test_many_remove_all_widgets():
|
||||
"""It should be possible to remove all widgets on a multi-widget screen."""
|
||||
async with App().run_test() as pilot:
|
||||
@@ -20,6 +22,7 @@ async def test_many_remove_all_widgets():
|
||||
await pilot.app.query(Static).remove()
|
||||
assert len(pilot.app.screen.children) == 0
|
||||
|
||||
|
||||
async def test_many_remove_some_widgets():
|
||||
"""It should be possible to remove some widgets on a multi-widget screen."""
|
||||
async with App().run_test() as pilot:
|
||||
@@ -28,70 +31,33 @@ async def test_many_remove_some_widgets():
|
||||
await pilot.app.query(".is-0").remove()
|
||||
assert len(pilot.app.screen.children) == 5
|
||||
|
||||
|
||||
async def test_remove_branch():
|
||||
"""It should be possible to remove a whole branch in the DOM."""
|
||||
async with App().run_test() as pilot:
|
||||
await pilot.app.mount(
|
||||
Container(
|
||||
Container(
|
||||
Container(
|
||||
Container(
|
||||
Container(
|
||||
Static()
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
),
|
||||
Container(Container(Container(Container(Container(Static()))))),
|
||||
Static(),
|
||||
Container(
|
||||
Container(
|
||||
Container(
|
||||
Container(
|
||||
Container(
|
||||
Static()
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
),
|
||||
Container(Container(Container(Container(Container(Static()))))),
|
||||
)
|
||||
assert len(pilot.app.screen.walk_children(with_self=False)) == 13
|
||||
await pilot.app.screen.children[0].remove()
|
||||
assert len(pilot.app.screen.walk_children(with_self=False)) == 7
|
||||
|
||||
|
||||
async def test_remove_overlap():
|
||||
"""It should be possible to remove an overlapping collection of widgets."""
|
||||
async with App().run_test() as pilot:
|
||||
await pilot.app.mount(
|
||||
Container(
|
||||
Container(
|
||||
Container(
|
||||
Container(
|
||||
Container(
|
||||
Static()
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
),
|
||||
Container(Container(Container(Container(Container(Static()))))),
|
||||
Static(),
|
||||
Container(
|
||||
Container(
|
||||
Container(
|
||||
Container(
|
||||
Container(
|
||||
Static()
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
),
|
||||
Container(Container(Container(Container(Container(Static()))))),
|
||||
)
|
||||
assert len(pilot.app.screen.walk_children(with_self=False)) == 13
|
||||
await pilot.app.query(Container).remove()
|
||||
assert len(pilot.app.screen.walk_children(with_self=False)) == 1
|
||||
|
||||
|
||||
async def test_remove_move_focus():
|
||||
"""Removing a focused widget should settle focus elsewhere."""
|
||||
async with App().run_test() as pilot:
|
||||
@@ -109,6 +75,7 @@ async def test_remove_move_focus():
|
||||
assert pilot.app.focused is not None
|
||||
assert pilot.app.focused == buttons[9]
|
||||
|
||||
|
||||
async def test_widget_remove_order():
|
||||
"""A Widget.remove of a top-level widget should cause bottom-first removal."""
|
||||
|
||||
@@ -127,6 +94,7 @@ async def test_widget_remove_order():
|
||||
assert len(pilot.app.screen.walk_children(with_self=False)) == 0
|
||||
assert removals == ["grandchild", "child", "parent"]
|
||||
|
||||
|
||||
async def test_query_remove_order():
|
||||
"""A DOMQuery.remove of a top-level widget should cause bottom-first removal."""
|
||||
|
||||
|
||||
Reference in New Issue
Block a user