mirror of
https://github.com/Textualize/textual.git
synced 2025-10-17 02:38:12 +03:00
Add unit tests for mounting relative to -2
To satisfy https://github.com/Textualize/textual/pull/1095#discussion_r1013041338
This commit is contained in:
@@ -37,6 +37,20 @@ async def test_mount_via_app() -> None:
|
||||
await pilot.app.mount(ultimate, after=-1)
|
||||
assert pilot.app.screen.children[-1] == ultimate
|
||||
|
||||
async with App().run_test() as pilot:
|
||||
# Mount a widget before -2, which is "before the penultimate".
|
||||
penpenultimate = Static(id="penpenultimate")
|
||||
await pilot.app.mount_all(widgets)
|
||||
await pilot.app.mount(penpenultimate, before=-2)
|
||||
assert pilot.app.screen.children[-3] == penpenultimate
|
||||
|
||||
async with App().run_test() as pilot:
|
||||
# Mount a widget after -2, which is "before the end".
|
||||
penultimate = Static(id="penultimate")
|
||||
await pilot.app.mount_all(widgets)
|
||||
await pilot.app.mount(penultimate, after=-2)
|
||||
assert pilot.app.screen.children[-2] == penultimate
|
||||
|
||||
async with App().run_test() as pilot:
|
||||
# Mount a widget before 0, which is "at the start".
|
||||
start = Static(id="start")
|
||||
|
||||
Reference in New Issue
Block a user