From 06e45c709e6b272a1c1358e307c8589af5737604 Mon Sep 17 00:00:00 2001 From: Dave Pearson Date: Tue, 13 Dec 2022 10:02:44 +0000 Subject: [PATCH] Add an alpha binding and key press to the focused widget test This is going to become important in the next test I'm intending to add, so it feels sensible to mirror the intended addition here too. --- tests/test_binding_inheritance.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/tests/test_binding_inheritance.py b/tests/test_binding_inheritance.py index e631c2ffc..9d7bbd363 100644 --- a/tests/test_binding_inheritance.py +++ b/tests/test_binding_inheritance.py @@ -139,7 +139,10 @@ async def test_pressing_movement_keys_app() -> None: class WidgetWithBindings(Static, can_focus=True): """A widget that has its own bindings for the movement keys.""" - BINDINGS = [Binding(key, f"local_record('{key}')", key) for key in MOVEMENT_KEYS] + BINDINGS = [ + Binding("x", "record('x')", "x"), + *[Binding(key, f"local_record('{key}')", key) for key in MOVEMENT_KEYS] + ] async def action_local_record(self, key: str) -> None: # Sneaky forward reference. Just for the purposes of testing. @@ -159,5 +162,5 @@ class AppWithWidgetWithBindings(AppKeyRecorder): async def test_focused_child_widget_with_movement_bindings() -> None: """A focused child widget with movement bindings should handle its own actions.""" async with AppWithWidgetWithBindings().run_test() as pilot: - await pilot.press(*MOVEMENT_KEYS) - assert pilot.app.pressed_keys == [f"locally_{key}" for key in MOVEMENT_KEYS] + await pilot.press("x", *MOVEMENT_KEYS, "x") + assert pilot.app.pressed_keys == ["x", *[f"locally_{key}" for key in MOVEMENT_KEYS], "x"]