Skip to content

Commit

Permalink
Fix failing tests
Browse files Browse the repository at this point in the history
  • Loading branch information
gselzer committed Aug 12, 2024
1 parent feb5933 commit 6923df2
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/napari_imagej/types/converters/images.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ def _image_layer_to_dataset(image: Image, **kwargs) -> "jc.Dataset":
for i in range(dataset.numDimensions()):
axis = dataset.axis(i)
# Overwrite EnumeratedAxes with LinearAxes
if isinstance(axis, jc.EnumeratedAxis):
if isinstance(axis, (jc.EnumeratedAxis, jc.DefaultLinearAxis)):
# Copy the dim name, unless it's unnamed
# in that case, assign it with X/Y/Z, if they aren't used already
if any(x in axis.type().getLabel() for x in ["dim", "Unknown"]) and len(
Expand Down
2 changes: 1 addition & 1 deletion src/napari_imagej/widgets/parameter_widgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ def _default_layer(self) -> Optional[Layer]:
the (first) input. We find the (first) input in this function.
"""
# Attempt to guess a good size based off of the first image input
for widget in self.parent._magic_widget.parent._magic_widget:
for widget in self.parent:
if widget is self:
continue
if isinstance(widget, ComboBox) and issubclass(widget.annotation, Layer):
Expand Down
11 changes: 9 additions & 2 deletions tests/widgets/test_napari_imagej.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,17 @@ 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:
for k, _ in viewer.keymap.items():
if str(k) == kb:
return True
return False

viewer: Viewer = make_napari_viewer()
assert "Control-L" not in viewer.keymap
assert not find_keybind("Ctrl+L")
NapariImageJWidget(viewer)
assert "Control-L" in viewer.keymap
assert find_keybind("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 6923df2

Please sign in to comment.