From 87e18de6056f98b2795b41724bf9a3c6c646d7cb Mon Sep 17 00:00:00 2001 From: Dave Pearson Date: Tue, 13 Dec 2022 21:56:43 +0000 Subject: [PATCH] Move the assert on key records into all_recorded While what I had worked, asserting on a boolean return from that method ended up masking what had gone wrong. This way we get to see the fail and *why* it failed. --- tests/test_binding_inheritance.py | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/tests/test_binding_inheritance.py b/tests/test_binding_inheritance.py index af3889ee6..d9085c8dd 100644 --- a/tests/test_binding_inheritance.py +++ b/tests/test_binding_inheritance.py @@ -188,16 +188,13 @@ class AppKeyRecorder(App[None]): """ self.pressed_keys.append(key) - def all_recorded(self, prefix: str="") -> bool: + def all_recorded(self, prefix: str="") -> None: """Were all the bindings recorded from the presses? Args: prefix (str, optional): An optional prefix. - - Returns: - bool: ``True`` if all the bindings were recorded, ``False``if not. """ - return self.pressed_keys == [f"{prefix}{key}" for key in self.ALL_KEYS] + assert self.pressed_keys == [f"{prefix}{key}" for key in self.ALL_KEYS] ############################################################################## @@ -229,7 +226,7 @@ async def test_pressing_movement_keys_app() -> None: async with AppWithMovementKeysBound().run_test() as pilot: await pilot.press(*AppKeyRecorder.ALL_KEYS) await pilot.pause(2/100) - assert pilot.app.all_recorded() + pilot.app.all_recorded() ############################################################################## @@ -265,7 +262,7 @@ async def test_focused_child_widget_with_movement_bindings() -> None: async with AppWithWidgetWithBindings().run_test() as pilot: await pilot.press(*AppKeyRecorder.ALL_KEYS) await pilot.pause(2/100) - assert pilot.app.all_recorded("locally_") + pilot.app.all_recorded("locally_") ############################################################################## # A focused widget within a screen that handles bindings. @@ -346,7 +343,7 @@ async def test_focused_child_widget_with_movement_bindings_no_inherit() -> None: async with AppWithWidgetWithBindingsNoInherit().run_test() as pilot: await pilot.press(*AppKeyRecorder.ALL_KEYS) await pilot.pause(2/100) - assert pilot.app.all_recorded("locally_") + pilot.app.all_recorded("locally_") ############################################################################## # A focused widget with no bindings and no inheriting of bindings, on screen. @@ -391,7 +388,7 @@ async def test_focused_child_widget_no_inherit_with_movement_bindings_on_screen( async with AppWithScreenWithBindingsWidgetNoBindingsNoInherit().run_test() as pilot: await pilot.press(*AppKeyRecorder.ALL_KEYS) await pilot.pause(2/100) - assert pilot.app.all_recorded("screenly_") + pilot.app.all_recorded("screenly_") ############################################################################## # A focused widget with zero bindings declared, but no inheriting of @@ -438,4 +435,4 @@ async def test_focused_child_widget_no_inherit_empty_bindings_with_movement_bind async with AppWithScreenWithBindingsWidgetEmptyBindingsNoInherit().run_test() as pilot: await pilot.press(*AppKeyRecorder.ALL_KEYS) await pilot.pause(2/100) - assert pilot.app.all_recorded("screenly_") + pilot.app.all_recorded("screenly_")