test for is_attached

This commit is contained in:
Will McGugan
2023-02-09 11:17:41 +00:00
parent 6b91501ade
commit 93acc27482
2 changed files with 16 additions and 3 deletions

View File

@@ -8,9 +8,13 @@ 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:
await pilot.app.mount(Static())
widget = Static()
assert not widget.is_attached
await pilot.app.mount(widget)
assert widget.is_attached
assert len(pilot.app.screen.children) == 1
await pilot.app.query_one(Static).remove()
assert not widget.is_attached
assert len(pilot.app.screen.children) == 0