Skip to content

Commit 512af0c

Browse files
committed
Add a test for the shown_keys property
1 parent f0068ac commit 512af0c

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

tests/test_binding.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
from string import ascii_lowercase
2+
13
import pytest
24

35
from textual.binding import Bindings, Binding, BindingError, NoBinding
@@ -38,3 +40,11 @@ def test_bad_binding_tuple():
3840

3941
def test_binding_from_tuples():
4042
assert Bindings((( BINDING2.key, BINDING2.action, BINDING2.description),)).get_key("c") == BINDING2
43+
44+
def test_shown():
45+
bindings = Bindings([
46+
Binding(
47+
key, action=f"action_{key}", description=f"Emits {key}",show=bool(ord(key)%2)
48+
) for key in ascii_lowercase
49+
])
50+
assert len(bindings.shown_keys)==(len(ascii_lowercase)/2)

0 commit comments

Comments
 (0)