code
stringlengths
66
870k
docstring
stringlengths
19
26.7k
func_name
stringlengths
1
138
language
stringclasses
1 value
repo
stringlengths
7
68
path
stringlengths
5
324
url
stringlengths
46
389
license
stringclasses
7 values
def test_sample_menu_single_data( make_napari_viewer, tmp_plugin: DynamicPlugin, ): """Checks sample submenu correct when plugin has single sample data.""" app = get_app_model() sample = SampleDataURI( key='tmp-sample-1', display_name='Temp Sample One', uri='some-file.tif', ...
Checks sample submenu correct when plugin has single sample data.
test_sample_menu_single_data
python
napari/napari
src/napari/_qt/_qapp_model/_tests/test_file_menu.py
https://github.com/napari/napari/blob/master/src/napari/_qt/_qapp_model/_tests/test_file_menu.py
BSD-3-Clause
def test_open( make_napari_viewer, action_id, dialog_method, dialog_return, filename_call, stack, ): """Test base `Open ...` actions can be triggered.""" make_napari_viewer() app = get_app_model() # Check action command execution with ( mock.patch('napari._qt.qt_view...
Test base `Open ...` actions can be triggered.
test_open
python
napari/napari
src/napari/_qt/_qapp_model/_tests/test_file_menu.py
https://github.com/napari/napari/blob/master/src/napari/_qt/_qapp_model/_tests/test_file_menu.py
BSD-3-Clause
def test_preference_dialog(make_napari_viewer): """Test preferences action can be triggered.""" make_napari_viewer() app = get_app_model() # Check action command execution with ( mock.patch( 'napari._qt.qt_main_window.PreferencesDialog.show' ) as mock_pref_dialog_show, ...
Test preferences action can be triggered.
test_preference_dialog
python
napari/napari
src/napari/_qt/_qapp_model/_tests/test_file_menu.py
https://github.com/napari/napari/blob/master/src/napari/_qt/_qapp_model/_tests/test_file_menu.py
BSD-3-Clause
def test_save_layers_enablement_updated_context(make_napari_viewer, builtins): """Test that enablement status of save layer actions updated correctly.""" get_app_model() viewer = make_napari_viewer() save_layers_action = viewer.window.file_menu.findAction( 'napari.window.file.save_layers_dialog...
Test that enablement status of save layer actions updated correctly.
test_save_layers_enablement_updated_context
python
napari/napari
src/napari/_qt/_qapp_model/_tests/test_file_menu.py
https://github.com/napari/napari/blob/master/src/napari/_qt/_qapp_model/_tests/test_file_menu.py
BSD-3-Clause
def test_save_layers( make_napari_viewer, action_id, dialog_method, dialog_return ): """Test save layer selected/all actions can be triggered.""" viewer = make_napari_viewer() app = get_app_model() # Add selected layer layer = Image(np.random.random((10, 10))) viewer.layers.append(layer) ...
Test save layer selected/all actions can be triggered.
test_save_layers
python
napari/napari
src/napari/_qt/_qapp_model/_tests/test_file_menu.py
https://github.com/napari/napari/blob/master/src/napari/_qt/_qapp_model/_tests/test_file_menu.py
BSD-3-Clause
def test_screenshot( make_napari_viewer, action_id, patch_method, dialog_return ): """Test screenshot actions can be triggered.""" make_napari_viewer() app = get_app_model() # Check action command execution with mock.patch(patch_method) as mock_screenshot: mock_screenshot.return_value =...
Test screenshot actions can be triggered.
test_screenshot
python
napari/napari
src/napari/_qt/_qapp_model/_tests/test_file_menu.py
https://github.com/napari/napari/blob/master/src/napari/_qt/_qapp_model/_tests/test_file_menu.py
BSD-3-Clause
def test_screenshot_to_clipboard(make_napari_viewer, qtbot, action_id): """Test screenshot to clipboard actions can be triggered.""" viewer = make_napari_viewer() app = get_app_model() # Add selected layer layer = Image(np.random.random((10, 10))) viewer.layers.append(layer) assert len(view...
Test screenshot to clipboard actions can be triggered.
test_screenshot_to_clipboard
python
napari/napari
src/napari/_qt/_qapp_model/_tests/test_file_menu.py
https://github.com/napari/napari/blob/master/src/napari/_qt/_qapp_model/_tests/test_file_menu.py
BSD-3-Clause
def test_close(make_napari_viewer, action_id, patch_method, method_params): """Test close/exit actions can be triggered.""" make_napari_viewer() app = get_app_model() quit_app, confirm_need = method_params # Check action command execution with mock.patch(patch_method) as mock_close: app...
Test close/exit actions can be triggered.
test_close
python
napari/napari
src/napari/_qt/_qapp_model/_tests/test_file_menu.py
https://github.com/napari/napari/blob/master/src/napari/_qt/_qapp_model/_tests/test_file_menu.py
BSD-3-Clause
def test_layer_actions_ctx_menu_execute_command( layer_action, make_napari_viewer ): """ Test layer context menu actions via app-model `execute_command`. Note: This test is here only to ensure app-model action dispatch mechanism is working for these actions (which use the `_provide_acti...
Test layer context menu actions via app-model `execute_command`. Note: This test is here only to ensure app-model action dispatch mechanism is working for these actions (which use the `_provide_active_layer_list` provider). To check a set of functional tests related to these actions y...
test_layer_actions_ctx_menu_execute_command
python
napari/napari
src/napari/_qt/_qapp_model/_tests/test_layerlist_context_actions.py
https://github.com/napari/napari/blob/master/src/napari/_qt/_qapp_model/_tests/test_layerlist_context_actions.py
BSD-3-Clause
def test_plugin_manager_action(make_napari_viewer): """ Test manage plugins installation action. The test is skipped in case `napari_plugin_manager` is not available """ app = get_app_model() viewer = make_napari_viewer() with mock.patch( 'napari_plugin_manager.qt_plugin_dialog.QtP...
Test manage plugins installation action. The test is skipped in case `napari_plugin_manager` is not available
test_plugin_manager_action
python
napari/napari
src/napari/_qt/_qapp_model/_tests/test_plugins_menu.py
https://github.com/napari/napari/blob/master/src/napari/_qt/_qapp_model/_tests/test_plugins_menu.py
BSD-3-Clause
def test_plugin_single_widget_menu( make_napari_viewer, tmp_plugin: DynamicPlugin ): """Test single plugin widgets get added to the window menu correctly.""" @tmp_plugin.contribute.widget(display_name='Widget 1') def widget1(): return DummyWidget() app = get_app_model() viewer = make_n...
Test single plugin widgets get added to the window menu correctly.
test_plugin_single_widget_menu
python
napari/napari
src/napari/_qt/_qapp_model/_tests/test_plugins_menu.py
https://github.com/napari/napari/blob/master/src/napari/_qt/_qapp_model/_tests/test_plugins_menu.py
BSD-3-Clause
def test_plugin_multiple_widget_menu( make_napari_viewer, tmp_plugin: DynamicPlugin, ): """Check plugin with >1 widgets added with submenu and uses 'display_name'.""" @tmp_plugin.contribute.widget(display_name='Widget 1') def widget1(): return DummyWidget() @tmp_plugin.contribute.widge...
Check plugin with >1 widgets added with submenu and uses 'display_name'.
test_plugin_multiple_widget_menu
python
napari/napari
src/napari/_qt/_qapp_model/_tests/test_plugins_menu.py
https://github.com/napari/napari/blob/master/src/napari/_qt/_qapp_model/_tests/test_plugins_menu.py
BSD-3-Clause
def test_plugin_menu_plugin_state_change( make_napari_viewer, tmp_plugin: DynamicPlugin, ): """Check plugin menu items correct after a plugin changes state.""" app = get_app_model() pm = tmp_plugin.plugin_manager # Register plugin q actions init_qactions() # Check only `Q_PLUGINS_ACTION...
Check plugin menu items correct after a plugin changes state.
test_plugin_menu_plugin_state_change
python
napari/napari
src/napari/_qt/_qapp_model/_tests/test_plugins_menu.py
https://github.com/napari/napari/blob/master/src/napari/_qt/_qapp_model/_tests/test_plugins_menu.py
BSD-3-Clause
def test_plugin_widget_checked( make_napari_viewer, qtbot, tmp_plugin: DynamicPlugin ): """Check widget toggling/hiding updates check mark correctly.""" @tmp_plugin.contribute.widget(display_name='Widget') def widget_contrib(): return DummyWidget() app = get_app_model() viewer = make_n...
Check widget toggling/hiding updates check mark correctly.
test_plugin_widget_checked
python
napari/napari
src/napari/_qt/_qapp_model/_tests/test_plugins_menu.py
https://github.com/napari/napari/blob/master/src/napari/_qt/_qapp_model/_tests/test_plugins_menu.py
BSD-3-Clause
def test_plugin_manager(make_napari_viewer): """Test that the plugin manager is accessible from the viewer""" viewer = make_napari_viewer() assert _plugins._plugin_manager_dialog_avail() # Check plugin install action is visible plugin_install_action = viewer.window.plugins_menu.findAction( ...
Test that the plugin manager is accessible from the viewer
test_plugin_manager
python
napari/napari
src/napari/_qt/_qapp_model/_tests/test_plugins_menu.py
https://github.com/napari/napari/blob/master/src/napari/_qt/_qapp_model/_tests/test_plugins_menu.py
BSD-3-Clause
def test_no_plugin_manager(monkeypatch, make_napari_viewer): """Test that the plugin manager menu item is hidden when not installed.""" def mockreturn(*args): return None monkeypatch.setattr('importlib.util.find_spec', mockreturn) # We need to reload `_plugins` for the monkeypatching to work ...
Test that the plugin manager menu item is hidden when not installed.
test_no_plugin_manager
python
napari/napari
src/napari/_qt/_qapp_model/_tests/test_plugins_menu.py
https://github.com/napari/napari/blob/master/src/napari/_qt/_qapp_model/_tests/test_plugins_menu.py
BSD-3-Clause
def test_copy_scale_to_clipboard(layer_list): """This is the test that checks copying scale to clipboard and pasting it to another layer. The layer_list contains three layers, l1, l2 and l3. The l2 is selected and l1 has a non-default scale. The test copy it to from l1 to l2 and check if l3 is not ...
This is the test that checks copying scale to clipboard and pasting it to another layer. The layer_list contains three layers, l1, l2 and l3. The l2 is selected and l1 has a non-default scale. The test copy it to from l1 to l2 and check if l3 is not affected. It also checks if the translate is not ...
test_copy_scale_to_clipboard
python
napari/napari
src/napari/_qt/_qapp_model/_tests/test_qaction_layer.py
https://github.com/napari/napari/blob/master/src/napari/_qt/_qapp_model/_tests/test_qaction_layer.py
BSD-3-Clause
def test_copy_units_to_clipboard(layer_list): """This is the test that checks copying units to clipboard and pasting it to another layer. The layer_list contains three layers, l1, l2 and l3. The l2 is selected and l1 has non-default units. The test copy it to from l1 to l2 and check if l3 is not af...
This is the test that checks copying units to clipboard and pasting it to another layer. The layer_list contains three layers, l1, l2 and l3. The l2 is selected and l1 has non-default units. The test copy it to from l1 to l2 and check if l3 is not affected. it also checks if the scale is not copied...
test_copy_units_to_clipboard
python
napari/napari
src/napari/_qt/_qapp_model/_tests/test_qaction_layer.py
https://github.com/napari/napari/blob/master/src/napari/_qt/_qapp_model/_tests/test_qaction_layer.py
BSD-3-Clause
def test_copy_translate_to_clipboard(layer_list): """This is the test that checks of copying translate to clipboard and pasting it to another layer. The layer_list contains three layers, l1, l2 and l3. The l2 is selected and l1 has non-default translate. The test copy it to from l1 to l2 and check ...
This is the test that checks of copying translate to clipboard and pasting it to another layer. The layer_list contains three layers, l1, l2 and l3. The l2 is selected and l1 has non-default translate. The test copy it to from l1 to l2 and check if l3 is not affected. It also checks if the scale is...
test_copy_translate_to_clipboard
python
napari/napari
src/napari/_qt/_qapp_model/_tests/test_qaction_layer.py
https://github.com/napari/napari/blob/master/src/napari/_qt/_qapp_model/_tests/test_qaction_layer.py
BSD-3-Clause
def test_copy_rotate_to_clipboard(layer_list): """This is the test that checks copying rotate to clipboard and pasting it to another layer. The layer_list contains three layers, l1, l2 and l3. The l2 is selected and l1 has non-default rotate. The test copy it to from l1 to l2 and check if l3 is not...
This is the test that checks copying rotate to clipboard and pasting it to another layer. The layer_list contains three layers, l1, l2 and l3. The l2 is selected and l1 has non-default rotate. The test copy it to from l1 to l2 and check if l3 is not affected. It also checks if the scale is not copi...
test_copy_rotate_to_clipboard
python
napari/napari
src/napari/_qt/_qapp_model/_tests/test_qaction_layer.py
https://github.com/napari/napari/blob/master/src/napari/_qt/_qapp_model/_tests/test_qaction_layer.py
BSD-3-Clause
def test_copy_affine_to_clipboard(layer_list): """This is the test that checks copying affine to clipboard and pasting it to another layer. The layer_list contains three layers, l1, l2 and l3. The l2 is selected and l1 has non-default affine. The test copy it to from l1 to l2 and check if l3 is not...
This is the test that checks copying affine to clipboard and pasting it to another layer. The layer_list contains three layers, l1, l2 and l3. The l2 is selected and l1 has non-default affine. The test copy it to from l1 to l2 and check if l3 is not affected. It also checks if the scale is not copi...
test_copy_affine_to_clipboard
python
napari/napari
src/napari/_qt/_qapp_model/_tests/test_qaction_layer.py
https://github.com/napari/napari/blob/master/src/napari/_qt/_qapp_model/_tests/test_qaction_layer.py
BSD-3-Clause
def test_copy_shear_to_clipboard(layer_list): """This is the test that checks copying shear to clipboard and pasting it to another layer. The layer_list contains three layers, l1, l2 and l3. The l2 is selected and l1 has non-default shear. The test copy it to from l1 to l2 and check if l3 is not af...
This is the test that checks copying shear to clipboard and pasting it to another layer. The layer_list contains three layers, l1, l2 and l3. The l2 is selected and l1 has non-default shear. The test copy it to from l1 to l2 and check if l3 is not affected. It also checks if the scale is not copied...
test_copy_shear_to_clipboard
python
napari/napari
src/napari/_qt/_qapp_model/_tests/test_qaction_layer.py
https://github.com/napari/napari/blob/master/src/napari/_qt/_qapp_model/_tests/test_qaction_layer.py
BSD-3-Clause
def test_copy_spatial_to_clipboard(layer_list): """This is the test that checks copying spatial to clipboard and pasting it to another layer. The layer_list contains three layers, l1, l2 and l3. The l2 is selected and l1 has non-default spatial metadata. The test copy it to from l1 to l2 and check ...
This is the test that checks copying spatial to clipboard and pasting it to another layer. The layer_list contains three layers, l1, l2 and l3. The l2 is selected and l1 has non-default spatial metadata. The test copy it to from l1 to l2 and check if l3 is not affected.
test_copy_spatial_to_clipboard
python
napari/napari
src/napari/_qt/_qapp_model/_tests/test_qaction_layer.py
https://github.com/napari/napari/blob/master/src/napari/_qt/_qapp_model/_tests/test_qaction_layer.py
BSD-3-Clause
def test_copy_spatial_to_clipboard_different_dim(layer_list_dim): """This is the test that checks copying spatial information from layer with higher dimensionality to layer with lower dimensionality. The layer_list_dim contains two layers, l1 and l2. The l1 contains 3D data and l2 contains 2D data....
This is the test that checks copying spatial information from layer with higher dimensionality to layer with lower dimensionality. The layer_list_dim contains two layers, l1 and l2. The l1 contains 3D data and l2 contains 2D data. The l2 is selected and l1 has non-default spatial metadata.
test_copy_spatial_to_clipboard_different_dim
python
napari/napari
src/napari/_qt/_qapp_model/_tests/test_qaction_layer.py
https://github.com/napari/napari/blob/master/src/napari/_qt/_qapp_model/_tests/test_qaction_layer.py
BSD-3-Clause
def test_build_qmodel_menu(builtins, make_napari_viewer, qtbot, menu_id): """Test that we can build qmenus for all registered menu IDs.""" app = get_app_model() # Configures `app`, registers actions and initializes plugins make_napari_viewer() menu = build_qmodel_menu(menu_id) qtbot.addWidget(...
Test that we can build qmenus for all registered menu IDs.
test_build_qmodel_menu
python
napari/napari
src/napari/_qt/_qapp_model/_tests/test_qapp_model_menus.py
https://github.com/napari/napari/blob/master/src/napari/_qt/_qapp_model/_tests/test_qapp_model_menus.py
BSD-3-Clause
def test_update_menu_state_context(make_napari_viewer): """Test `_update_menu_state` correctly updates enabled/visible state.""" app = get_app_model() viewer = make_napari_viewer() action = Action( id='dummy_id', title='dummy title', callback=lambda: None, menus=[{'id': ...
Test `_update_menu_state` correctly updates enabled/visible state.
test_update_menu_state_context
python
napari/napari
src/napari/_qt/_qapp_model/_tests/test_qapp_model_menus.py
https://github.com/napari/napari/blob/master/src/napari/_qt/_qapp_model/_tests/test_qapp_model_menus.py
BSD-3-Clause
def test_publicproxy_provide_viewer(capsys, make_napari_viewer): """Test `_provide_viewer` outputs a `PublicOnlyProxy` when appropriate. Check manual (e.g., internal) `_provide_viewer` calls can disable `PublicOnlyProxy` via `public_proxy` parameter but `PublicOnlyProxy` is always used when it is used ...
Test `_provide_viewer` outputs a `PublicOnlyProxy` when appropriate. Check manual (e.g., internal) `_provide_viewer` calls can disable `PublicOnlyProxy` via `public_proxy` parameter but `PublicOnlyProxy` is always used when it is used as a provider.
test_publicproxy_provide_viewer
python
napari/napari
src/napari/_qt/_qapp_model/_tests/test_qproviders.py
https://github.com/napari/napari/blob/master/src/napari/_qt/_qapp_model/_tests/test_qproviders.py
BSD-3-Clause
def test_provide_viewer_or_raise(make_napari_viewer): """Check `_provide_viewer_or_raise` raises or returns correct `Viewer`.""" # raises when no viewer with pytest.raises(RuntimeError, match='No current `Viewer` found. test'): _provide_viewer_or_raise(msg='test') # create viewer make_napar...
Check `_provide_viewer_or_raise` raises or returns correct `Viewer`.
test_provide_viewer_or_raise
python
napari/napari
src/napari/_qt/_qapp_model/_tests/test_qproviders.py
https://github.com/napari/napari/blob/master/src/napari/_qt/_qapp_model/_tests/test_qproviders.py
BSD-3-Clause
def test_toggle_axes_scale_bar_attr( action_id, action_title, viewer_attr, sub_attr ): """ Test toggle actions related with viewer axes and scale bar attributes. * Viewer `axes` attributes: * `visible` * `colored` * `labels` * `dashed` * `arrows` * Viewer `sc...
Test toggle actions related with viewer axes and scale bar attributes. * Viewer `axes` attributes: * `visible` * `colored` * `labels` * `dashed` * `arrows` * Viewer `scale_bar` attributes: * `visible` * `box` * `colored` * `ticks` ...
test_toggle_axes_scale_bar_attr
python
napari/napari
src/napari/_qt/_qapp_model/_tests/test_view_menu.py
https://github.com/napari/napari/blob/master/src/napari/_qt/_qapp_model/_tests/test_view_menu.py
BSD-3-Clause
def test_toggle_fullscreen_from_normal(make_napari_viewer, qtbot): """ Test toggle fullscreen action from normal window state. Check that toggling from a normal state can be done without generating any type of warning and menu bar elements are visible in any window state. """ action_id = 'n...
Test toggle fullscreen action from normal window state. Check that toggling from a normal state can be done without generating any type of warning and menu bar elements are visible in any window state.
test_toggle_fullscreen_from_normal
python
napari/napari
src/napari/_qt/_qapp_model/_tests/test_view_menu.py
https://github.com/napari/napari/blob/master/src/napari/_qt/_qapp_model/_tests/test_view_menu.py
BSD-3-Clause
def test_toggle_fullscreen_from_maximized(make_napari_viewer, qtbot): """ Test toggle fullscreen action from maximized window state. Check that toggling from a maximized state can be done without generating any type of warning and menu bar elements are visible in any window state. """ actio...
Test toggle fullscreen action from maximized window state. Check that toggling from a maximized state can be done without generating any type of warning and menu bar elements are visible in any window state.
test_toggle_fullscreen_from_maximized
python
napari/napari
src/napari/_qt/_qapp_model/_tests/test_view_menu.py
https://github.com/napari/napari/blob/master/src/napari/_qt/_qapp_model/_tests/test_view_menu.py
BSD-3-Clause
def test_toggle_menubar(make_napari_viewer, qtbot): """ Test menubar toggle functionality. Skipped on macOS since the menubar is the system one so the menubar toggle action doesn't exist/isn't enabled there. """ action_id = 'napari.window.view.toggle_menubar' app = get_app_model() viewe...
Test menubar toggle functionality. Skipped on macOS since the menubar is the system one so the menubar toggle action doesn't exist/isn't enabled there.
test_toggle_menubar
python
napari/napari
src/napari/_qt/_qapp_model/_tests/test_view_menu.py
https://github.com/napari/napari/blob/master/src/napari/_qt/_qapp_model/_tests/test_view_menu.py
BSD-3-Clause
def test_toggle_canvas_ndim(initial, expected): """Check that _toggle_canvas_ndim toggles the canvas ndims.""" viewer = ViewerModel() viewer.dims.ndisplay = initial _toggle_canvas_ndim(viewer) assert viewer.dims.ndisplay == expected
Check that _toggle_canvas_ndim toggles the canvas ndims.
test_toggle_canvas_ndim
python
napari/napari
src/napari/_qt/_qapp_model/_tests/test_view_menu.py
https://github.com/napari/napari/blob/master/src/napari/_qt/_qapp_model/_tests/test_view_menu.py
BSD-3-Clause
def get_submenu_action(qmodel_menu, submenu_text, action_text): """ Get an action that belongs to a submenu inside a `QModelMenu` instance. Needed since `QModelMenu.findAction` will not search inside submenu actions Parameters ---------- qmodel_menu : app_model.backends.qt.QModelMenu O...
Get an action that belongs to a submenu inside a `QModelMenu` instance. Needed since `QModelMenu.findAction` will not search inside submenu actions Parameters ---------- qmodel_menu : app_model.backends.qt.QModelMenu One of the application menus created via `napari._qt._qapp_model.build_q...
get_submenu_action
python
napari/napari
src/napari/_qt/_qapp_model/_tests/utils.py
https://github.com/napari/napari/blob/master/src/napari/_qt/_qapp_model/_tests/utils.py
BSD-3-Clause
def _rebuild_npe1_samples_menu() -> None: # pragma: no cover """Register submenu and actions for all npe1 plugins, clearing all first.""" app = get_app_model() # Unregister all existing npe1 sample menu actions and submenus if unreg := plugin_manager._unreg_sample_submenus: unreg() if unreg...
Register submenu and actions for all npe1 plugins, clearing all first.
_rebuild_npe1_samples_menu
python
napari/napari
src/napari/_qt/_qplugins/_qnpe2.py
https://github.com/napari/napari/blob/master/src/napari/_qt/_qplugins/_qnpe2.py
BSD-3-Clause
def _toggle_or_get_widget_npe1( plugin: str, widget_name: str, name: str, hook_type: str, ) -> None: # pragma: no cover """Toggle if widget already built otherwise return widget for npe1.""" window = _provide_window_or_raise( msg='Note that widgets cannot be opened in headless mode.' ...
Toggle if widget already built otherwise return widget for npe1.
_toggle_or_get_widget_npe1
python
napari/napari
src/napari/_qt/_qplugins/_qnpe2.py
https://github.com/napari/napari/blob/master/src/napari/_qt/_qplugins/_qnpe2.py
BSD-3-Clause
def _rebuild_npe1_plugins_menu() -> None: """Register widget submenu and actions for all npe1 plugins, clearing all first.""" app = get_app_model() # Unregister all existing npe1 plugin menu actions and submenus if unreg := plugin_manager._unreg_plugin_submenus: unreg() if unreg := plugin_m...
Register widget submenu and actions for all npe1 plugins, clearing all first.
_rebuild_npe1_plugins_menu
python
napari/napari
src/napari/_qt/_qplugins/_qnpe2.py
https://github.com/napari/napari/blob/master/src/napari/_qt/_qplugins/_qnpe2.py
BSD-3-Clause
def _get_contrib_parent_menu( multiprovider: bool, parent_menu: MenuId, mf: PluginManifest, group: str | None = None, ) -> tuple[str, list[tuple[str, SubmenuItem]]]: """Get parent menu of plugin contribution (samples/widgets). If plugin provides multiple contributions, create a new submenu item...
Get parent menu of plugin contribution (samples/widgets). If plugin provides multiple contributions, create a new submenu item.
_get_contrib_parent_menu
python
napari/napari
src/napari/_qt/_qplugins/_qnpe2.py
https://github.com/napari/napari/blob/master/src/napari/_qt/_qplugins/_qnpe2.py
BSD-3-Clause
def _build_samples_submenu_actions( mf: PluginManifest, ) -> tuple[list[tuple[str, SubmenuItem]], list[Action]]: """Build sample data submenu and actions for a single npe2 plugin manifest.""" from napari._app_model.constants import MenuGroup, MenuId from napari.plugins import menu_item_template # I...
Build sample data submenu and actions for a single npe2 plugin manifest.
_build_samples_submenu_actions
python
napari/napari
src/napari/_qt/_qplugins/_qnpe2.py
https://github.com/napari/napari/blob/master/src/napari/_qt/_qplugins/_qnpe2.py
BSD-3-Clause
def _get_widget_viewer_param( widget_callable: WidgetCreator, widget_name: str ) -> str: """Get widget parameter name for `viewer` (if any) and check type.""" if inspect.isclass(widget_callable) and issubclass( widget_callable, QWidget | Widget, ): widget_param = '' try: ...
Get widget parameter name for `viewer` (if any) and check type.
_get_widget_viewer_param
python
napari/napari
src/napari/_qt/_qplugins/_qnpe2.py
https://github.com/napari/napari/blob/master/src/napari/_qt/_qplugins/_qnpe2.py
BSD-3-Clause
def _toggle_or_get_widget( plugin: str, widget_name: str, full_name: str, ) -> tuple[FunctionGui | QWidget | Widget, str] | None: """Toggle if widget already built otherwise return widget. Returned widget will be added to main window by a processor. Note for magicgui type widget contributions, ...
Toggle if widget already built otherwise return widget. Returned widget will be added to main window by a processor. Note for magicgui type widget contributions, `Viewer` injection is done by `magicgui.register_type` instead of a provider via annnotation.
_toggle_or_get_widget
python
napari/napari
src/napari/_qt/_qplugins/_qnpe2.py
https://github.com/napari/napari/blob/master/src/napari/_qt/_qplugins/_qnpe2.py
BSD-3-Clause
def _build_widgets_submenu_actions( mf: PluginManifest, ) -> tuple[list[tuple[str, SubmenuItem]], list[Action]]: """Build widget submenu and actions for a single npe2 plugin manifest.""" from napari._app_model.constants._menus import is_menu_contributable # If no widgets, return if not mf.contribut...
Build widget submenu and actions for a single npe2 plugin manifest.
_build_widgets_submenu_actions
python
napari/napari
src/napari/_qt/_qplugins/_qnpe2.py
https://github.com/napari/napari/blob/master/src/napari/_qt/_qplugins/_qnpe2.py
BSD-3-Clause
def _register_qt_actions(mf: PluginManifest) -> None: """Register samples and widget actions and submenus from a manifest. This is called when a plugin is registered or enabled and it adds the plugin's sample and widget actions and submenus to the app model registry. """ app = get_app_model() s...
Register samples and widget actions and submenus from a manifest. This is called when a plugin is registered or enabled and it adds the plugin's sample and widget actions and submenus to the app model registry.
_register_qt_actions
python
napari/napari
src/napari/_qt/_qplugins/_qnpe2.py
https://github.com/napari/napari/blob/master/src/napari/_qt/_qplugins/_qnpe2.py
BSD-3-Clause
def test_run_outside_ipython(make_napari_viewer, qapp, monkeypatch): """Test that we don't incorrectly give ipython the event loop.""" assert not _ipython_has_eventloop() v1 = make_napari_viewer() assert not _ipython_has_eventloop() v2 = make_napari_viewer() assert not _ipython_has_eventloop() ...
Test that we don't incorrectly give ipython the event loop.
test_run_outside_ipython
python
napari/napari
src/napari/_qt/_tests/test_app.py
https://github.com/napari/napari/blob/master/src/napari/_qt/_tests/test_app.py
BSD-3-Clause
def _enable_async(_fresh_settings, make_napari_viewer): """ This fixture depends on _fresh_settings and make_napari_viewer to enforce proper order of fixture execution. """ from napari import settings settings.get_settings().experimental.async_ = True
This fixture depends on _fresh_settings and make_napari_viewer to enforce proper order of fixture execution.
_enable_async
python
napari/napari
src/napari/_qt/_tests/test_async_slicing.py
https://github.com/napari/napari/blob/master/src/napari/_qt/_tests/test_async_slicing.py
BSD-3-Clause
def test_async_out_of_bounds_layer_loaded(make_napari_viewer, qtbot): """Check that images that are out of bounds when slicing appear loaded. See https://github.com/napari/napari/issues/7070. """ viewer = make_napari_viewer() l0 = viewer.add_image(np.random.random((5, 5, 5))) l1 = viewer.add_im...
Check that images that are out of bounds when slicing appear loaded. See https://github.com/napari/napari/issues/7070.
test_async_out_of_bounds_layer_loaded
python
napari/napari
src/napari/_qt/_tests/test_async_slicing.py
https://github.com/napari/napari/blob/master/src/napari/_qt/_tests/test_async_slicing.py
BSD-3-Clause
def test_async_slice_two_layers_shutdown(make_napari_viewer): """See https://github.com/napari/napari/issues/6685""" viewer = make_napari_viewer() # To reproduce the issue, we need two points layers where the second has # some non-zero coordinates. viewer.add_points() points = viewer.add_points(...
See https://github.com/napari/napari/issues/6685
test_async_slice_two_layers_shutdown
python
napari/napari
src/napari/_qt/_tests/test_async_slicing.py
https://github.com/napari/napari/blob/master/src/napari/_qt/_tests/test_async_slicing.py
BSD-3-Clause
def test_open_files_dialog(make_napari_viewer, stack): """Check `QtViewer._open_files_dialog` correnct when `stack=True`.""" viewer = make_napari_viewer() with ( mock.patch( 'napari._qt.qt_viewer.QtViewer._open_file_dialog_uni' ) as mock_file, mock.patch('napari._qt.qt_vi...
Check `QtViewer._open_files_dialog` correnct when `stack=True`.
test_open_files_dialog
python
napari/napari
src/napari/_qt/_tests/test_open_file.py
https://github.com/napari/napari/blob/master/src/napari/_qt/_tests/test_open_file.py
BSD-3-Clause
def test_dock_widget_registration( arg, napari_plugin_manager, request, recwarn ): """Test that dock widgets get validated and registered correctly.""" class Plugin: @napari_hook_implementation def napari_experimental_provide_dock_widget(): return arg napari_plugin_manager....
Test that dock widgets get validated and registered correctly.
test_dock_widget_registration
python
napari/napari
src/napari/_qt/_tests/test_plugin_widgets.py
https://github.com/napari/napari/blob/master/src/napari/_qt/_tests/test_plugin_widgets.py
BSD-3-Clause
def test_inject_viewer_proxy(make_napari_viewer): """Test that the injected viewer is a public-only proxy""" viewer = make_napari_viewer() wdg = _instantiate_dock_widget(Widg3, viewer) assert isinstance(wdg.viewer, PublicOnlyProxy) # simulate access from outside napari with patch('napari.utils....
Test that the injected viewer is a public-only proxy
test_inject_viewer_proxy
python
napari/napari
src/napari/_qt/_tests/test_plugin_widgets.py
https://github.com/napari/napari/blob/master/src/napari/_qt/_tests/test_plugin_widgets.py
BSD-3-Clause
def test_get_widget_viewer_param_error(): """Test incorrect subclass raises error in `_get_widget_viewer_param`.""" with pytest.raises(TypeError) as e: _get_widget_viewer_param(ErrorWidget, 'widget_name') assert "'widget_name' must be `QtWidgets.QWidget`" in str(e)
Test incorrect subclass raises error in `_get_widget_viewer_param`.
test_get_widget_viewer_param_error
python
napari/napari
src/napari/_qt/_tests/test_plugin_widgets.py
https://github.com/napari/napari/blob/master/src/napari/_qt/_tests/test_plugin_widgets.py
BSD-3-Clause
def test_widget_hide_destroy(make_napari_viewer, qtbot): """Test that widget hide and destroy works.""" viewer = make_napari_viewer() viewer.window.add_dock_widget(QWidget_example(viewer), name='test') dock_widget = viewer.window._dock_widgets['test'] # Check widget persists after hide widget =...
Test that widget hide and destroy works.
test_widget_hide_destroy
python
napari/napari
src/napari/_qt/_tests/test_plugin_widgets.py
https://github.com/napari/napari/blob/master/src/napari/_qt/_tests/test_plugin_widgets.py
BSD-3-Clause
def test_widget_types_supported( make_napari_viewer, tmp_plugin: DynamicPlugin, Widget, ): """Test all supported widget types correctly instantiated and call processor. The 4 parametrized `Widget`s represent the varing widget constructors and signatures that we want to support. """ # Us...
Test all supported widget types correctly instantiated and call processor. The 4 parametrized `Widget`s represent the varing widget constructors and signatures that we want to support.
test_widget_types_supported
python
napari/napari
src/napari/_qt/_tests/test_plugin_widgets.py
https://github.com/napari/napari/blob/master/src/napari/_qt/_tests/test_plugin_widgets.py
BSD-3-Clause
def test_qt_tooltip_event_filter(qtbot, tooltip, is_qt_tag_present): """ Check that the tooltip event filter only changes tooltips with non-rich text. """ from qtpy.QtCore import QEvent from qtpy.QtWidgets import QWidget # event filter object and QEvent event_filter_handler = QtToolTipEvent...
Check that the tooltip event filter only changes tooltips with non-rich text.
test_qt_tooltip_event_filter
python
napari/napari
src/napari/_qt/_tests/test_qt_event_filters.py
https://github.com/napari/napari/blob/master/src/napari/_qt/_tests/test_qt_event_filters.py
BSD-3-Clause
def test_clean_current_path_exist(make_napari_viewer): """If this test fail then you need to fix also clean_current fixture""" assert isinstance( make_napari_viewer().window._qt_viewer._welcome_widget, QWidget )
If this test fail then you need to fix also clean_current fixture
test_clean_current_path_exist
python
napari/napari
src/napari/_qt/_tests/test_qt_notifications.py
https://github.com/napari/napari/blob/master/src/napari/_qt/_tests/test_qt_notifications.py
BSD-3-Clause
def test_notification_manager_via_gui( count_show, qtbot, raise_func, warn_func, monkeypatch ): """ Test that the notification_manager intercepts `sys.excepthook`` and `threading.excepthook`. """ errButton = QPushButton() warnButton = QPushButton() errButton.clicked.connect(raise_func) ...
Test that the notification_manager intercepts `sys.excepthook`` and `threading.excepthook`.
test_notification_manager_via_gui
python
napari/napari
src/napari/_qt/_tests/test_qt_notifications.py
https://github.com/napari/napari/blob/master/src/napari/_qt/_tests/test_qt_notifications.py
BSD-3-Clause
def test_notifications_error_with_threading(make_napari_viewer, monkeypatch): """Test notifications of `threading` threads, using a dask example.""" random_image = da.random.random((10, 10)) monkeypatch.setattr( NapariQtNotification, 'show_notification', lambda x: None ) with notification_ma...
Test notifications of `threading` threads, using a dask example.
test_notifications_error_with_threading
python
napari/napari
src/napari/_qt/_tests/test_qt_notifications.py
https://github.com/napari/napari/blob/master/src/napari/_qt/_tests/test_qt_notifications.py
BSD-3-Clause
def test_signal_blocker(qtbot): """make sure context manager signal blocker works""" import pytestqt.exceptions obj = Emitter() # make sure signal works with qtbot.waitSignal(obj.test_signal): obj.go() # make sure blocker works with qt_signals_blocked(obj): with pytest.rai...
make sure context manager signal blocker works
test_signal_blocker
python
napari/napari
src/napari/_qt/_tests/test_qt_utils.py
https://github.com/napari/napari/blob/master/src/napari/_qt/_tests/test_qt_utils.py
BSD-3-Clause
def test_qt_viewer_console_focus(qtbot, make_napari_viewer): """Test console has focus when instantiating from viewer.""" viewer = make_napari_viewer(show=True) view = viewer.window._qt_viewer assert not view.console.hasFocus(), 'console has focus before being shown' view.toggle_console_visibility(...
Test console has focus when instantiating from viewer.
test_qt_viewer_console_focus
python
napari/napari
src/napari/_qt/_tests/test_qt_viewer.py
https://github.com/napari/napari/blob/master/src/napari/_qt/_tests/test_qt_viewer.py
BSD-3-Clause
def test_z_order_adding_removing_images(make_napari_viewer): """Test z order is correct after adding/ removing images.""" data = np.ones((10, 10)) viewer = make_napari_viewer() vis = viewer.window._qt_viewer.canvas.layer_to_visual viewer.add_image(data, colormap='red', name='red') viewer.add_im...
Test z order is correct after adding/ removing images.
test_z_order_adding_removing_images
python
napari/napari
src/napari/_qt/_tests/test_qt_viewer.py
https://github.com/napari/napari/blob/master/src/napari/_qt/_tests/test_qt_viewer.py
BSD-3-Clause
def test_process_mouse_event(make_napari_viewer): """Test that the correct properties are added to the MouseEvent by _process_mouse_events. """ # make a mock mouse event new_pos = (25, 25) mouse_event = MouseEvent( type='mouse_press', pos=new_pos, ) data = np.zeros((5, 20...
Test that the correct properties are added to the MouseEvent by _process_mouse_events.
test_process_mouse_event
python
napari/napari
src/napari/_qt/_tests/test_qt_viewer.py
https://github.com/napari/napari/blob/master/src/napari/_qt/_tests/test_qt_viewer.py
BSD-3-Clause
def test_process_mouse_event_2d_layer_3d_viewer(make_napari_viewer): """Test that _process_mouse_events can handle 2d layers in 3D. This is a test for: https://github.com/napari/napari/issues/7299 """ # make a mock mouse event new_pos = (5, 5) mouse_event = MouseEvent( type='mouse_pres...
Test that _process_mouse_events can handle 2d layers in 3D. This is a test for: https://github.com/napari/napari/issues/7299
test_process_mouse_event_2d_layer_3d_viewer
python
napari/napari
src/napari/_qt/_tests/test_qt_viewer.py
https://github.com/napari/napari/blob/master/src/napari/_qt/_tests/test_qt_viewer.py
BSD-3-Clause
def test_canvas_color(make_napari_viewer, theme): """Test instantiating viewer with different themes. See: https://github.com/napari/napari/issues/3278 """ # This test is to make sure the application starts with # with different themes get_settings().appearance.theme = theme viewer = make_n...
Test instantiating viewer with different themes. See: https://github.com/napari/napari/issues/3278
test_canvas_color
python
napari/napari
src/napari/_qt/_tests/test_qt_viewer.py
https://github.com/napari/napari/blob/master/src/napari/_qt/_tests/test_qt_viewer.py
BSD-3-Clause
def test_remove_add_image_3D(make_napari_viewer): """ Test that adding, removing and readding an image layer in 3D does not cause issues due to the vispy node change. See https://github.com/napari/napari/pull/3670 """ viewer = make_napari_viewer(ndisplay=3) img = np.ones((10, 10, 10)) layer...
Test that adding, removing and readding an image layer in 3D does not cause issues due to the vispy node change. See https://github.com/napari/napari/pull/3670
test_remove_add_image_3D
python
napari/napari
src/napari/_qt/_tests/test_qt_viewer.py
https://github.com/napari/napari/blob/master/src/napari/_qt/_tests/test_qt_viewer.py
BSD-3-Clause
def test_qt_viewer_multscale_image_out_of_view(make_napari_viewer): """Test out-of-view multiscale image viewing fix. Just verifies that no RuntimeError is raised in this scenario. see: https://github.com/napari/napari/issues/3863. """ # show=True required to test fix for OpenGL error viewer =...
Test out-of-view multiscale image viewing fix. Just verifies that no RuntimeError is raised in this scenario. see: https://github.com/napari/napari/issues/3863.
test_qt_viewer_multscale_image_out_of_view
python
napari/napari
src/napari/_qt/_tests/test_qt_viewer.py
https://github.com/napari/napari/blob/master/src/napari/_qt/_tests/test_qt_viewer.py
BSD-3-Clause
def test_surface_mixed_dim(make_napari_viewer): """Test that adding a layer that changes the world ndim when ndisplay=3 before the mouse cursor has been updated doesn't raise an error. See PR: https://github.com/napari/napari/pull/3881 """ viewer = make_napari_viewer(ndisplay=3) verts = np...
Test that adding a layer that changes the world ndim when ndisplay=3 before the mouse cursor has been updated doesn't raise an error. See PR: https://github.com/napari/napari/pull/3881
test_surface_mixed_dim
python
napari/napari
src/napari/_qt/_tests/test_qt_viewer.py
https://github.com/napari/napari/blob/master/src/napari/_qt/_tests/test_qt_viewer.py
BSD-3-Clause
def test_insert_layer_ordering(make_napari_viewer): """make sure layer ordering is correct in vispy when inserting layers""" viewer = make_napari_viewer() pl1 = Points() pl2 = Points() viewer.layers.append(pl1) viewer.layers.insert(0, pl2) pl1_vispy = viewer.window._qt_viewer.canvas.layer_...
make sure layer ordering is correct in vispy when inserting layers
test_insert_layer_ordering
python
napari/napari
src/napari/_qt/_tests/test_qt_viewer.py
https://github.com/napari/napari/blob/master/src/napari/_qt/_tests/test_qt_viewer.py
BSD-3-Clause
def _update_data( layer: Labels, label: int, qtbot: QtBot, qt_viewer: QtViewer, dtype: np.dtype = np.uint64, ) -> tuple[np.ndarray, np.ndarray]: """Change layer data and return color of label and middle pixel of screenshot.""" layer.data = np.full((2, 2), label, dtype=dtype) layer.select...
Change layer data and return color of label and middle pixel of screenshot.
_update_data
python
napari/napari
src/napari/_qt/_tests/test_qt_viewer.py
https://github.com/napari/napari/blob/master/src/napari/_qt/_tests/test_qt_viewer.py
BSD-3-Clause
def test_label_colors_matching_widget_auto( qtbot, qt_viewer_with_controls, use_selection, dtype ): """Make sure the rendered label colors match the QtColorBox widget.""" # XXX TODO: this unstable! Seed = 0 fails, for example. This is due to numerical # imprecision in random colormap on gpu v...
Make sure the rendered label colors match the QtColorBox widget.
test_label_colors_matching_widget_auto
python
napari/napari
src/napari/_qt/_tests/test_qt_viewer.py
https://github.com/napari/napari/blob/master/src/napari/_qt/_tests/test_qt_viewer.py
BSD-3-Clause
def _find_margin(data: np.ndarray, additional_margin: int) -> tuple[int, int]: """ helper function to determine margins in test_thumbnail_labels """ mid_x, mid_y = data.shape[0] // 2, data.shape[1] // 2 x_margin = len( list(takewhile(lambda x: np.all(x == 0), data[:, mid_y, :3][::-1])) ...
helper function to determine margins in test_thumbnail_labels
_find_margin
python
napari/napari
src/napari/_qt/_tests/test_qt_viewer.py
https://github.com/napari/napari/blob/master/src/napari/_qt/_tests/test_qt_viewer.py
BSD-3-Clause
def test_points_2d_to_3d(make_napari_viewer): """See https://github.com/napari/napari/issues/6925""" # this requires a full viewer cause some issues are caused only by # qt processing events viewer = make_napari_viewer(ndisplay=2, show=True) viewer.add_points() QApplication.processEvents() v...
See https://github.com/napari/napari/issues/6925
test_points_2d_to_3d
python
napari/napari
src/napari/_qt/_tests/test_qt_viewer.py
https://github.com/napari/napari/blob/master/src/napari/_qt/_tests/test_qt_viewer.py
BSD-3-Clause
def test_qt_viewer_data_integrity(make_napari_viewer, dtype): """Test that the viewer doesn't change the underlying array.""" image = np.random.rand(10, 32, 32) image *= 200 if dtype.endswith('8') else 2**14 image = image.astype(dtype) imean = image.mean() viewer = make_napari_viewer() laye...
Test that the viewer doesn't change the underlying array.
test_qt_viewer_data_integrity
python
napari/napari
src/napari/_qt/_tests/test_qt_viewer_2.py
https://github.com/napari/napari/blob/master/src/napari/_qt/_tests/test_qt_viewer_2.py
BSD-3-Clause
def test_current_viewer(make_napari_viewer): """Test that we can retrieve the "current" viewer window easily. ... where "current" means it was the last viewer the user interacted with. """ assert _QtMainWindow.current() is None # when we create a new viewer it becomes accessible at Viewer.current(...
Test that we can retrieve the "current" viewer window easily. ... where "current" means it was the last viewer the user interacted with.
test_current_viewer
python
napari/napari
src/napari/_qt/_tests/test_qt_window.py
https://github.com/napari/napari/blob/master/src/napari/_qt/_tests/test_qt_window.py
BSD-3-Clause
def test_screenshot_to_file(make_napari_viewer, tmp_path): """ Test taking a screenshot using the Window instance and saving it to a file. """ viewer = make_napari_viewer() screenshot_file_path = str(tmp_path / 'screenshot.png') np.random.seed(0) # Add image data = np.random.random((10,...
Test taking a screenshot using the Window instance and saving it to a file.
test_screenshot_to_file
python
napari/napari
src/napari/_qt/_tests/test_qt_window.py
https://github.com/napari/napari/blob/master/src/napari/_qt/_tests/test_qt_window.py
BSD-3-Clause
def test_terminate_no_ref(monkeypatch): """Test that the thread terminates when the viewer is garbage collected.""" model = ViewerModel() status_checker = StatusChecker(model) del model status_checker.run() assert not status_checker._terminate
Test that the thread terminates when the viewer is garbage collected.
test_terminate_no_ref
python
napari/napari
src/napari/_qt/_tests/test_threads.py
https://github.com/napari/napari/blob/master/src/napari/_qt/_tests/test_threads.py
BSD-3-Clause
def test_4D_5D_images(make_napari_viewer): """Test adding 4D followed by 5D image layers to the viewer. Initially only 2 sliders should be present, then a third slider should be created. """ np.random.seed(0) viewer = make_napari_viewer() view = viewer.window._qt_viewer # add 4D image ...
Test adding 4D followed by 5D image layers to the viewer. Initially only 2 sliders should be present, then a third slider should be created.
test_4D_5D_images
python
napari/napari
src/napari/_tests/test_advanced.py
https://github.com/napari/napari/blob/master/src/napari/_tests/test_advanced.py
BSD-3-Clause
def test_change_image_dims(make_napari_viewer): """Test changing the dims and shape of an image layer in place and checking the numbers of sliders and their ranges changes appropriately. """ np.random.seed(0) viewer = make_napari_viewer() view = viewer.window._qt_viewer # add 3D image data ...
Test changing the dims and shape of an image layer in place and checking the numbers of sliders and their ranges changes appropriately.
test_change_image_dims
python
napari/napari
src/napari/_tests/test_advanced.py
https://github.com/napari/napari/blob/master/src/napari/_tests/test_advanced.py
BSD-3-Clause
def test_range_one_image(make_napari_viewer): """Test adding an image with a range one dimensions. There should be no slider shown for the axis corresponding to the range one dimension. """ np.random.seed(0) viewer = make_napari_viewer() view = viewer.window._qt_viewer # add 5D image d...
Test adding an image with a range one dimensions. There should be no slider shown for the axis corresponding to the range one dimension.
test_range_one_image
python
napari/napari
src/napari/_tests/test_advanced.py
https://github.com/napari/napari/blob/master/src/napari/_tests/test_advanced.py
BSD-3-Clause
def test_range_one_images_and_points(make_napari_viewer): """Test adding images with range one dimensions and points. Initially no sliders should be present as the images have range one dimensions. On adding the points the sliders should be displayed. """ np.random.seed(0) viewer = make_napari_...
Test adding images with range one dimensions and points. Initially no sliders should be present as the images have range one dimensions. On adding the points the sliders should be displayed.
test_range_one_images_and_points
python
napari/napari
src/napari/_tests/test_advanced.py
https://github.com/napari/napari/blob/master/src/napari/_tests/test_advanced.py
BSD-3-Clause
def test_update_console(make_napari_viewer): """Test updating the console with local variables.""" viewer = make_napari_viewer() view = viewer.window._qt_viewer # Check viewer in console assert view.console.kernel_client is not None assert 'viewer' in view.console.shell.user_ns assert view....
Test updating the console with local variables.
test_update_console
python
napari/napari
src/napari/_tests/test_advanced.py
https://github.com/napari/napari/blob/master/src/napari/_tests/test_advanced.py
BSD-3-Clause
def test_update_lazy_console(make_napari_viewer, caplog): """Test updating the console with local variables, before console is instantiated.""" viewer = make_napari_viewer() view = viewer.window._qt_viewer a = 4 b = 5 viewer.update_console(['a', 'b']) x = np.arange(5) viewer.update...
Test updating the console with local variables, before console is instantiated.
test_update_lazy_console
python
napari/napari
src/napari/_tests/test_advanced.py
https://github.com/napari/napari/blob/master/src/napari/_tests/test_advanced.py
BSD-3-Clause
def test_changing_display_surface(make_napari_viewer): """Test adding 3D surface and changing its display.""" viewer = make_napari_viewer() view = viewer.window._qt_viewer np.random.seed(0) vertices = 20 * np.random.random((10, 3)) faces = np.random.randint(10, size=(6, 3)) values = np.rand...
Test adding 3D surface and changing its display.
test_changing_display_surface
python
napari/napari
src/napari/_tests/test_advanced.py
https://github.com/napari/napari/blob/master/src/napari/_tests/test_advanced.py
BSD-3-Clause
def test_labels_undo_redo(make_napari_viewer): """Test undoing/redoing on the labels layer.""" viewer = make_napari_viewer() data = np.zeros((50, 50), dtype=np.uint8) data[:5, :5] = 1 data[5:10, 5:10] = 2 data[25:, 25:] = 3 labels = viewer.add_labels(data) l1 = labels.data.copy() ...
Test undoing/redoing on the labels layer.
test_labels_undo_redo
python
napari/napari
src/napari/_tests/test_advanced.py
https://github.com/napari/napari/blob/master/src/napari/_tests/test_advanced.py
BSD-3-Clause
def mock_run(): """mock to prevent starting the event loop.""" with mock.patch('napari._qt.widgets.qt_splash_screen.NapariSplashScreen'): with mock.patch('napari.run'): yield napari.run
mock to prevent starting the event loop.
mock_run
python
napari/napari
src/napari/_tests/test_cli.py
https://github.com/napari/napari/blob/master/src/napari/_tests/test_cli.py
BSD-3-Clause
def test_cli_works(monkeypatch, capsys): """Test the cli runs and shows help""" monkeypatch.setattr(sys, 'argv', ['napari', '-h']) with pytest.raises(SystemExit): __main__._run() assert 'napari command line viewer.' in str(capsys.readouterr())
Test the cli runs and shows help
test_cli_works
python
napari/napari
src/napari/_tests/test_cli.py
https://github.com/napari/napari/blob/master/src/napari/_tests/test_cli.py
BSD-3-Clause
def test_cli_shows_plugins(monkeypatch, capsys, tmp_plugin): """Test the cli --info runs and shows plugins""" monkeypatch.setattr(sys, 'argv', ['napari', '--info']) with pytest.raises(SystemExit): __main__._run() assert tmp_plugin.name in str(capsys.readouterr())
Test the cli --info runs and shows plugins
test_cli_shows_plugins
python
napari/napari
src/napari/_tests/test_cli.py
https://github.com/napari/napari/blob/master/src/napari/_tests/test_cli.py
BSD-3-Clause
def test_cli_parses_unknowns(mock_run, monkeypatch, make_napari_viewer): """test that we can parse layer keyword arg variants""" v = make_napari_viewer() # our mock view_path will return this object def assert_kwargs(*args, **kwargs): assert ['file'] in args assert kwargs['contrast_limits'...
test that we can parse layer keyword arg variants
test_cli_parses_unknowns
python
napari/napari
src/napari/_tests/test_cli.py
https://github.com/napari/napari/blob/master/src/napari/_tests/test_cli.py
BSD-3-Clause
def test_cli_raises(monkeypatch): """test that unknown kwargs raise the correct errors.""" with monkeypatch.context() as m: m.setattr(sys, 'argv', ['napari', 'path/to/file', '--nonsense']) with pytest.raises(SystemExit) as e: __main__._run() assert str(e.value) == 'error: unr...
test that unknown kwargs raise the correct errors.
test_cli_raises
python
napari/napari
src/napari/_tests/test_cli.py
https://github.com/napari/napari/blob/master/src/napari/_tests/test_cli.py
BSD-3-Clause
def test_cli_runscript(run_path, monkeypatch, tmp_path): """Test that running napari script.py runs a script""" script = tmp_path / 'test.py' script.write_text('import napari; v = napari.Viewer(show=False)') with monkeypatch.context() as m: m.setattr(sys, 'argv', ['napari', str(script)]) ...
Test that running napari script.py runs a script
test_cli_runscript
python
napari/napari
src/napari/_tests/test_cli.py
https://github.com/napari/napari/blob/master/src/napari/_tests/test_cli.py
BSD-3-Clause
def test_cli_retains_viewer_ref(mock_run, monkeypatch, make_napari_viewer): """Test that napari.__main__ is retaining a reference to the viewer.""" v = make_napari_viewer() # our mock view_path will return this object ref_count = None # counter that will be updated before __main__._run() def _check_r...
Test that napari.__main__ is retaining a reference to the viewer.
test_cli_retains_viewer_ref
python
napari/napari
src/napari/_tests/test_cli.py
https://github.com/napari/napari/blob/master/src/napari/_tests/test_cli.py
BSD-3-Clause
def test_lack_disable_throttle(monkeypatch): """This is test showing that if we do not use disable_throttling then timer is started""" mock = Mock() start_mock = Mock() active_mock = Mock(return_value=True) monkeypatch.setattr('qtpy.QtCore.QTimer.start', start_mock) monkeypatch.setattr('qtpy.QtC...
This is test showing that if we do not use disable_throttling then timer is started
test_lack_disable_throttle
python
napari/napari
src/napari/_tests/test_conftest_fixtures.py
https://github.com/napari/napari/blob/master/src/napari/_tests/test_conftest_fixtures.py
BSD-3-Clause
def test_canvas_drawing(make_napari_viewer): """Test drawing before and after adding and then deleting a layer.""" viewer = make_napari_viewer(show=True) view = viewer.window._qt_viewer view.set_welcome_visible(False) assert len(viewer.layers) == 0 # Check canvas context is not none before dra...
Test drawing before and after adding and then deleting a layer.
test_canvas_drawing
python
napari/napari
src/napari/_tests/test_draw.py
https://github.com/napari/napari/blob/master/src/napari/_tests/test_draw.py
BSD-3-Clause
def test_examples(builtins, fname, monkeypatch): """Test that all of our examples are still working without warnings.""" example_path = str(EXAMPLE_DIR / fname) monkeypatch.setattr(sys, 'argv', [fname]) _run_example(example_path)
Test that all of our examples are still working without warnings.
test_examples
python
napari/napari
src/napari/_tests/test_examples.py
https://github.com/napari/napari/blob/master/src/napari/_tests/test_examples.py
BSD-3-Clause
def test_dev_examples(fname, monkeypatch): """Test that all of our dev examples are still working without warnings.""" example_path = str(DEV_EXAMPLE_DIR / fname) monkeypatch.setattr(sys, 'argv', [fname]) _run_example(example_path)
Test that all of our dev examples are still working without warnings.
test_dev_examples
python
napari/napari
src/napari/_tests/test_examples.py
https://github.com/napari/napari/blob/master/src/napari/_tests/test_examples.py
BSD-3-Clause
def test_viewer_key_bindings(make_napari_viewer): """Test adding key bindings to the viewer""" np.random.seed(0) viewer = make_napari_viewer() canvas = viewer.window._qt_viewer.canvas mock_press = Mock() mock_release = Mock() mock_shift_press = Mock() mock_shift_release = Mock() @v...
Test adding key bindings to the viewer
test_viewer_key_bindings
python
napari/napari
src/napari/_tests/test_key_bindings.py
https://github.com/napari/napari/blob/master/src/napari/_tests/test_key_bindings.py
BSD-3-Clause
def test_layer_key_bindings(make_napari_viewer): """Test adding key bindings to a layer""" np.random.seed(0) viewer = make_napari_viewer() canvas = viewer.window._qt_viewer.canvas layer = viewer.add_image(np.random.random((10, 20))) viewer.layers.selection.add(layer) mock_press = Mock() ...
Test adding key bindings to a layer
test_layer_key_bindings
python
napari/napari
src/napari/_tests/test_key_bindings.py
https://github.com/napari/napari/blob/master/src/napari/_tests/test_key_bindings.py
BSD-3-Clause
def test_magicgui_add_data(make_napari_viewer, LayerType, data, ndim): """Test that annotating with napari.types.<layer_type>Data works. It expects a raw data format (like a numpy array) and will add a layer of the corresponding type to the viewer. """ viewer = make_napari_viewer() dtype = geta...
Test that annotating with napari.types.<layer_type>Data works. It expects a raw data format (like a numpy array) and will add a layer of the corresponding type to the viewer.
test_magicgui_add_data
python
napari/napari
src/napari/_tests/test_magicgui.py
https://github.com/napari/napari/blob/master/src/napari/_tests/test_magicgui.py
BSD-3-Clause
def test_magicgui_add_data_inheritance( make_napari_viewer, layer_and_type, image_layer ): """This test validates if the scale and translate are inherited from the previous layer when adding a new layer with magicgui if function requests, a LayerData type. """ layer, type_ = layer_and_type v...
This test validates if the scale and translate are inherited from the previous layer when adding a new layer with magicgui if function requests, a LayerData type.
test_magicgui_add_data_inheritance
python
napari/napari
src/napari/_tests/test_magicgui.py
https://github.com/napari/napari/blob/master/src/napari/_tests/test_magicgui.py
BSD-3-Clause
def test_magicgui_add_data_inheritance_two_layer(make_napari_viewer): """This test validates if the scale and translate are inherited if more than one source layer is passed to function when adding a new layer with magicgui if function requests, a LayerData type. """ rng = np.random.default_rng(0) ...
This test validates if the scale and translate are inherited if more than one source layer is passed to function when adding a new layer with magicgui if function requests, a LayerData type.
test_magicgui_add_data_inheritance_two_layer
python
napari/napari
src/napari/_tests/test_magicgui.py
https://github.com/napari/napari/blob/master/src/napari/_tests/test_magicgui.py
BSD-3-Clause
def test_magicgui_add_data_inheritance_two_layer_inconsistent( make_napari_viewer, monkeypatch ): """This test validates the scale and translate are not inherited from the previous layers with inconsistend metadata when adding a new layer with magicgui if function requests, a LayerData type. """...
This test validates the scale and translate are not inherited from the previous layers with inconsistend metadata when adding a new layer with magicgui if function requests, a LayerData type.
test_magicgui_add_data_inheritance_two_layer_inconsistent
python
napari/napari
src/napari/_tests/test_magicgui.py
https://github.com/napari/napari/blob/master/src/napari/_tests/test_magicgui.py
BSD-3-Clause