Skip to content

Commit

Permalink
snapshot
Browse files Browse the repository at this point in the history
  • Loading branch information
willmcgugan committed Sep 27, 2024
1 parent 985b6a7 commit 649967f
Show file tree
Hide file tree
Showing 2 changed files with 185 additions and 0 deletions.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
35 changes: 35 additions & 0 deletions tests/snapshot_tests/test_snapshots.py
Original file line number Diff line number Diff line change
Expand Up @@ -2019,3 +2019,38 @@ def action_toggle_console(self) -> None:

app = MRE()
assert snap_compare(app, press=["space", "space", "z"])


def test_pop_until_active(snap_compare):
class BaseScreen(Screen):
def compose(self) -> ComposeResult:
yield Label("BASE")

class FooScreen(Screen):
def compose(self) -> ComposeResult:
yield Label("Foo")

class BarScreen(Screen):
BINDINGS = [("b", "app.make_base_active")]

def compose(self) -> ComposeResult:
yield Label("Bar")

class PopApp(App):
SCREENS = {"base": BaseScreen}

async def on_mount(self) -> None:
# Push base
await self.push_screen("base")
# Push two screens
await self.push_screen(FooScreen())
await self.push_screen(BarScreen())

def action_make_base_active(self) -> None:
self.get_screen("base").pop_until_active()

app = PopApp()
# App will push three screens
# Pressing "b" will call pop_until_active, and pop two screens
# End result should be screen showing "BASE"
assert snap_compare(app, press=["b"])

0 comments on commit 649967f

Please sign in to comment.