mirror of
https://github.com/Textualize/textual.git
synced 2025-10-17 02:38:12 +03:00
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.
This commit is contained in:
@@ -6,12 +6,16 @@ from textual.binding import Bindings, Binding, BindingError, NoBinding
|
|||||||
|
|
||||||
BINDING1 = Binding("a,b", action="action1", description="description1")
|
BINDING1 = Binding("a,b", action="action1", description="description1")
|
||||||
BINDING2 = Binding("c", action="action2", description="description2")
|
BINDING2 = Binding("c", action="action2", description="description2")
|
||||||
|
BINDING3 = Binding(" d , e ", action="action3", description="description3")
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
def bindings():
|
def bindings():
|
||||||
yield Bindings([BINDING1, BINDING2])
|
yield Bindings([BINDING1, BINDING2])
|
||||||
|
|
||||||
|
@pytest.fixture
|
||||||
|
def more_bindings():
|
||||||
|
yield Bindings([BINDING1, BINDING2, BINDING3])
|
||||||
|
|
||||||
def test_bindings_get_key(bindings):
|
def test_bindings_get_key(bindings):
|
||||||
assert bindings.get_key("b") == Binding("b", action="action1", description="description1")
|
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):
|
with pytest.raises(NoBinding):
|
||||||
bindings.get_key("control+meta+alt+shift+super+hyper+t")
|
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):
|
def test_bindings_merge_simple(bindings):
|
||||||
left = Bindings([BINDING1])
|
left = Bindings([BINDING1])
|
||||||
right = Bindings([BINDING2])
|
right = Bindings([BINDING2])
|
||||||
|
|||||||
Reference in New Issue
Block a user