From 7f724f7668e24fad5830733ee54303cc84c350ec Mon Sep 17 00:00:00 2001 From: Will McGugan Date: Thu, 22 Aug 2024 13:51:31 +0100 Subject: [PATCH] harden test --- .../snapshot_tests/snapshot_apps/help_panel.py | 12 ------------ tests/snapshot_tests/test_snapshots.py | 17 ++++++++++++----- 2 files changed, 12 insertions(+), 17 deletions(-) delete mode 100644 tests/snapshot_tests/snapshot_apps/help_panel.py diff --git a/tests/snapshot_tests/snapshot_apps/help_panel.py b/tests/snapshot_tests/snapshot_apps/help_panel.py deleted file mode 100644 index 05512865be..0000000000 --- a/tests/snapshot_tests/snapshot_apps/help_panel.py +++ /dev/null @@ -1,12 +0,0 @@ -from textual.app import App, ComposeResult -from textual.widgets import Input - - -class HelpPanelApp(App): - def compose(self) -> ComposeResult: - yield Input() - - -if __name__ == "__main__": - app = HelpPanelApp() - app.run() diff --git a/tests/snapshot_tests/test_snapshots.py b/tests/snapshot_tests/test_snapshots.py index 87e3811bcd..8f421f7aa6 100644 --- a/tests/snapshot_tests/test_snapshots.py +++ b/tests/snapshot_tests/test_snapshots.py @@ -1467,11 +1467,18 @@ def compose(self) -> ComposeResult: def test_help_panel(snap_compare): """Test help panel.""" - assert snap_compare( - SNAPSHOT_APPS_DIR / "help_panel.py", - terminal_size=(100, 30), - press=["ctrl+p", *"keys", "enter"], - ) + class HelpPanelApp(App): + def compose(self) -> ComposeResult: + yield Input() + + async def run_before(pilot: Pilot): + await pilot.press(App.COMMAND_PALETTE_BINDING) + await pilot.pause() + await pilot.press(*"keys") + await pilot.press("enter") + await pilot.app.workers.wait_for_complete() + + assert snap_compare(HelpPanelApp(), terminal_size=(100, 30), run_before=run_before) def test_scroll_page_down(snap_compare):