tests: remove private magicgui access in tests
* test: remove private magicgui access
* remove full test
* Revert "remove full test"
This reverts commit
* fix magicgui.widgets namespace
* update docstring
@@ -287,18 +287,12 @@ NAMES = ('Image', 'Labels', 'Layer', 'Points', 'Shapes', 'Surface')
@pytest.mark.parametrize('name', sorted(MGUI_EXPORTS))
def test_mgui_forward_refs(name, monkeypatch):
- """Test magicgui forward ref annotations
-
- make sure that calling
- `magicgui.type_map.pick_widget_type` with the string version of a napari
- object triggers the appropriate imports to resolve the class in time.
+ """make sure that magicgui's `get_widget_class` returns the right widget type
+ for the various napari types... even when expressed as strings.
"""
- import magicgui.type_map
+ import magicgui.widgets
+ from magicgui.type_map import get_widget_class
- # clearing out the loaded modules that call magicgui.register_type,
- # to make sure that when the forward ref is evaluated, those modules get imported
- # again.
- monkeypatch.setattr(magicgui.type_map, '_TYPE_DEFS', {})
monkeypatch.delitem(sys.modules, 'napari')
monkeypatch.delitem(sys.modules, 'napari.viewer')
monkeypatch.delitem(sys.modules, 'napari.types')
@@ -309,8 +303,7 @@ def test_mgui_forward_refs(name, monkeypatch):
if m.startswith('napari.layers') and 'utils' not in m:
monkeypatch.delitem(sys.modules, m)
- assert magicgui.type_map._TYPE_DEFS == {}
- wdg, options = magicgui.type_map.pick_widget_type(annotation=name)
+ wdg, options = get_widget_class(annotation=name)
if name == 'napari.Viewer':
assert wdg == magicgui.widgets.EmptyWidget and 'bind' in options
else:
