Skip to content

Commit

Permalink
Check multiple keybinding strings
Browse files Browse the repository at this point in the history
napari <0.5.0 expects "Control-L", while napari >= 0.5.0 expects
"Ctrl+L"
  • Loading branch information
gselzer committed Sep 20, 2024
1 parent 9520532 commit da7caaa
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions tests/widgets/test_napari_imagej.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,16 +41,16 @@ def test_widget_subwidget_layout(imagej_widget: NapariImageJWidget):
def test_keymaps(make_napari_viewer, qtbot):
"""Tests that 'Ctrl+L' is added to the keymap by ImageJWidget"""

def find_keybind(kb: str) -> bool:
def find_keybind(kbs) -> bool:
for k, _ in viewer.keymap.items():
if str(k) == kb:
if str(k) in kbs:
return True
return False

viewer: Viewer = make_napari_viewer()
assert not find_keybind("Control-L")
assert not find_keybind(["Control-L", "Ctrl+L"])
NapariImageJWidget(viewer)
assert find_keybind("Control-L")
assert find_keybind(["Control-L", "Ctrl+L"])
# TODO: I can't seem to figure out how to assert that pressing 'L'
# sets the focus of the search bar.
# Typing viewer.keymap['L'](viewer) does nothing. :(
Expand Down

0 comments on commit da7caaa

Please sign in to comment.