From dcad134acd45211802c969d2422894460011ff1f Mon Sep 17 00:00:00 2001 From: Dave Pearson Date: Wed, 14 Dec 2022 17:29:47 +0000 Subject: [PATCH] Add a (currently) breaking test for spaces within a key list At the moment at least, we don't allow binding on " ", we bind on "space". Meanwhile, tidy folk may try and bind in "a, b, c, d" as opposed to trying to bind on "a,b,c,d". I feel we should allow for that. This test, which breaks at the moment, should be satisfied. --- tests/test_binding.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/tests/test_binding.py b/tests/test_binding.py index 620fbc03e..3c12f5a7c 100644 --- a/tests/test_binding.py +++ b/tests/test_binding.py @@ -6,12 +6,16 @@ from textual.binding import Bindings, Binding, BindingError, NoBinding BINDING1 = Binding("a,b", action="action1", description="description1") BINDING2 = Binding("c", action="action2", description="description2") +BINDING3 = Binding(" d , e ", action="action3", description="description3") @pytest.fixture def bindings(): yield Bindings([BINDING1, BINDING2]) +@pytest.fixture +def more_bindings(): + yield Bindings([BINDING1, BINDING2, BINDING3]) def test_bindings_get_key(bindings): assert bindings.get_key("b") == Binding("b", action="action1", description="description1") @@ -19,6 +23,9 @@ def test_bindings_get_key(bindings): with pytest.raises(NoBinding): bindings.get_key("control+meta+alt+shift+super+hyper+t") +def test_bindings_get_key_spaced_list(more_bindings): + assert more_bindings.get_key("d").action == more_bindings.get_key("e").action + def test_bindings_merge_simple(bindings): left = Bindings([BINDING1]) right = Bindings([BINDING2])