Skip to content

Commit dd7f0a3

Browse files
committed
test
1 parent e9e7acb commit dd7f0a3

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

tests/test_binding.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
InvalidBinding,
1111
NoBinding,
1212
)
13+
from textual.screen import Screen
1314

1415
BINDING1 = Binding("a,b", action="action1", description="description1")
1516
BINDING2 = Binding("c", action="action2", description="description2")
@@ -102,3 +103,27 @@ class BrokenApp(App):
102103

103104
class BrokenApp(App):
104105
BINDINGS = [(", ,", "foo", "Broken")]
106+
107+
108+
async def test_keymap_update() -> None:
109+
"""Check that when keymaps are updated, the bindings_updated signal is sent."""
110+
111+
bindings_updated: list[Screen] = []
112+
113+
class KeymapApp(App):
114+
BINDINGS = [Binding("q", "quit", "Quit", id="quit")]
115+
116+
def signal_bindings_updated(screen: Screen) -> None:
117+
bindings_updated.append(screen)
118+
119+
app = KeymapApp()
120+
async with app.run_test() as pilot:
121+
await pilot.pause()
122+
app.screen.bindings_updated_signal.subscribe(app, signal_bindings_updated)
123+
assert not bindings_updated
124+
app.set_keymap({"quit": "f1"})
125+
await pilot.pause()
126+
assert bindings_updated == [app.screen]
127+
app.set_keymap({"quit": "f1"})
128+
await pilot.pause()
129+
assert bindings_updated == [app.screen, app.screen]

0 commit comments

Comments
 (0)