mirror of
https://github.com/Textualize/textual.git
synced 2025-10-17 02:38:12 +03:00
Add a unit test for removal ordering via Widget.remove
This commit is contained in:
@@ -108,3 +108,19 @@ async def test_remove_move_focus():
|
||||
assert len(pilot.app.screen.walk_children(with_self=False)) == 6
|
||||
assert pilot.app.focused is not None
|
||||
assert pilot.app.focused == buttons[9]
|
||||
|
||||
async def test_remove_order():
|
||||
"""The removal of a top-level widget should cause bottom-first removal."""
|
||||
|
||||
removals: list[str] = []
|
||||
|
||||
class Removable(Container):
|
||||
def on_unmount( self, _ ):
|
||||
removals.append(self.id if self.id is not None else "unknown")
|
||||
|
||||
async with App().run_test() as pilot:
|
||||
await pilot.app.mount(
|
||||
Removable(Removable(Removable(id="grandchild"), id="child"), id="parent")
|
||||
)
|
||||
await pilot.app.screen.children[0].remove()
|
||||
assert removals == ["grandchild", "child", "parent"]
|
||||
|
||||
Reference in New Issue
Block a user