22
33These tests don't require a browser or a real Jupyter kernel: we just
44check that the static resources are self-consistent and that the
5- ``ProjectLibrary.ipywidget `` plumbing degrades gracefully when the
5+ ``ProjectLibrary.widget `` plumbing degrades gracefully when the
66optional ``anywidget`` dependency is unavailable.
77"""
88
@@ -86,14 +86,14 @@ def test_panel_css_and_js_are_strings():
8686
8787
8888def test_ipywidget_degrades_when_anywidget_missing (monkeypatch , tmp_path ):
89- """Without anywidget / ipywidgets , .ipywidget () raises ImportError
89+ """Without anywidget, .widget () raises ImportError
9090 and _ipython_display_ falls back to printing the repr."""
9191 try :
9292 import anywidget # noqa: F401
9393 except ImportError :
9494 lib = ProjectLibrary (str (tmp_path / "lib.json" ), auto_save = False )
9595 with pytest .raises (ImportError ):
96- lib .ipywidget ()
96+ lib .widget ()
9797
9898
9999def test_ipywidget_esm_builds ():
@@ -116,13 +116,12 @@ def test_ipywidget_esm_builds():
116116
117117
118118def test_ipywidget_construction_if_available (tmp_path ):
119- """If anywidget is available, ProjectLibrary.ipywidget () returns a
119+ """If anywidget is available, ProjectLibrary.widget () returns a
120120 widget with a non-empty _esm."""
121121 anywidget = pytest .importorskip ("anywidget" )
122- pytest .importorskip ("ipywidgets" )
123122
124123 lib = ProjectLibrary (str (tmp_path / "lib.json" ), auto_save = False )
125- widget = lib .ipywidget ()
124+ widget = lib .widget ()
126125 assert isinstance (widget , anywidget .AnyWidget )
127126 assert widget ._esm and "export function render" in widget ._esm
128127
@@ -136,7 +135,6 @@ def test_ipywidget_handlers_respond(tmp_path):
136135 report as 'the button doesn't work'.
137136 """
138137 pytest .importorskip ("anywidget" )
139- pytest .importorskip ("ipywidgets" )
140138 from projspec import Project
141139
142140 lib_file = tmp_path / "lib.json"
@@ -148,7 +146,7 @@ def test_ipywidget_handlers_respond(tmp_path):
148146 proj_url = "file://" + proj_path
149147 lib .entries [proj_url ] = Project (proj_path , walk = False )
150148
151- widget = lib .ipywidget ()
149+ widget = lib .widget ()
152150 outbox : list [dict ] = []
153151 toasts : list [str ] = []
154152 widget .send = lambda content , buffers = None : outbox .append (content )
@@ -257,7 +255,6 @@ def test_make_cwd_uses_project_path_not_library_key(tmp_path, monkeypatch):
257255 import fsspec
258256
259257 pytest .importorskip ("anywidget" )
260- pytest .importorskip ("ipywidgets" )
261258 from projspec .artifact .process import Process
262259 from projspec .proj .base import Project , ProjectSpec
263260 from projspec .utils import AttrDict , is_installed
@@ -297,7 +294,7 @@ def test_make_cwd_uses_project_path_not_library_key(tmp_path, monkeypatch):
297294
298295 # Kernel cwd is deliberately somewhere else.
299296 monkeypatch .chdir ("/" )
300- w = lib .ipywidget ()
297+ w = lib .widget ()
301298 w ._toast = lambda m : None
302299 w .send = lambda c , buffers = None : None
303300
0 commit comments