Skip to content

Commit eacd961

Browse files
Fix registry state lookup and CI (#3653)
* register is a function * some debugging of js tests * remove extra node_modules cache * bump action versions for deprecation warnings * more step naming * try some docs pins * test: create widget from frontend * remove ipykernel pin * remove ipykernel pin (conda) * fix test, setup and teardown messed things up, refactor * roll back ci changes to simplify ci * use ubuntu-20.04 for js CI Co-authored-by: Maarten A. Breddels <[email protected]>
1 parent f89c5d9 commit eacd961

File tree

4 files changed

+24
-27
lines changed

4 files changed

+24
-27
lines changed

.github/workflows/tests.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,8 @@ jobs:
3636
python -m sphinx -T -E -b html -d ../build/doctrees -D language=en . ../build/html
3737
js:
3838
name: JavaScript
39-
runs-on: ubuntu-latest
39+
# as of #3653 ubuntu-latest wasn't working
40+
runs-on: ubuntu-20.04
4041

4142
steps:
4243
- uses: actions/checkout@v2
@@ -50,7 +51,6 @@ jobs:
5051
**/requirements*.txt
5152
- name: Install dependencies
5253
run: |
53-
sudo apt-get install -y firefox
5454
python -m pip install --upgrade pip
5555
python -m pip install jupyterlab~=3.0
5656
- name: Install node

python/ipywidgets/ipywidgets/widgets/tests/test_send_state.py

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -12,29 +12,20 @@
1212
# A widget with simple traits
1313
class SimpleWidget(Widget):
1414
a = Bool().tag(sync=True)
15-
b = Tuple(Bool(), Bool(), Bool(), default_value=(False, False, False)).tag(sync=True)
15+
b = Tuple(Bool(), Bool(), Bool(), default_value=(False, False, False)).tag(
16+
sync=True
17+
)
1618
c = List(Bool()).tag(sync=True)
1719

20+
1821
def test_empty_send_state():
1922
w = SimpleWidget()
2023
w.send_state([])
2124
assert w.comm.messages == []
2225

26+
2327
def test_empty_hold_sync():
2428
w = SimpleWidget()
2529
with w.hold_sync():
2630
pass
2731
assert w.comm.messages == []
28-
29-
30-
def test_control():
31-
comm = DummyComm()
32-
Widget.close_all()
33-
w = SimpleWidget()
34-
Widget.handle_control_comm_opened(
35-
comm, dict(metadata={'version': __control_protocol_version__})
36-
)
37-
Widget._handle_control_comm_msg(dict(content=dict(
38-
data={'method': 'request_states'}
39-
)))
40-
assert comm.messages

python/ipywidgets/ipywidgets/widgets/tests/test_widget.py

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,18 @@
33

44
"""Test Widget."""
55

6+
import inspect
7+
8+
import pytest
69
from IPython.core.interactiveshell import InteractiveShell
710
from IPython.display import display
811
from IPython.utils.capture import capture_output
9-
import inspect
10-
import pytest
1112

1213
from .. import widget
1314
from ..widget import Widget
1415
from ..widget_button import Button
1516

17+
1618
def test_no_widget_view():
1719
# ensure IPython shell is instantiated
1820
# otherwise display() just calls print
@@ -24,10 +26,12 @@ def test_no_widget_view():
2426

2527
assert len(cap.outputs) == 1, "expect 1 output"
2628
mime_bundle = cap.outputs[0].data
27-
assert mime_bundle['text/plain'] == repr(w), "expected plain text output"
28-
assert 'application/vnd.jupyter.widget-view+json' not in mime_bundle, "widget has no view"
29-
assert cap.stdout == '', repr(cap.stdout)
30-
assert cap.stderr == '', repr(cap.stderr)
29+
assert mime_bundle["text/plain"] == repr(w), "expected plain text output"
30+
assert (
31+
"application/vnd.jupyter.widget-view+json" not in mime_bundle
32+
), "widget has no view"
33+
assert cap.stdout == "", repr(cap.stdout)
34+
assert cap.stderr == "", repr(cap.stderr)
3135

3236

3337
def test_widget_view():
@@ -41,10 +45,12 @@ def test_widget_view():
4145

4246
assert len(cap.outputs) == 1, "expect 1 output"
4347
mime_bundle = cap.outputs[0].data
44-
assert mime_bundle['text/plain'] == repr(w), "expected plain text output"
45-
assert 'application/vnd.jupyter.widget-view+json' in mime_bundle, "widget should have have a view"
46-
assert cap.stdout == '', repr(cap.stdout)
47-
assert cap.stderr == '', repr(cap.stderr)
48+
assert mime_bundle["text/plain"] == repr(w), "expected plain text output"
49+
assert (
50+
"application/vnd.jupyter.widget-view+json" in mime_bundle
51+
), "widget should have have a view"
52+
assert cap.stdout == "", repr(cap.stdout)
53+
assert cap.stderr == "", repr(cap.stderr)
4854

4955

5056
def test_close_all():

python/ipywidgets/ipywidgets/widgets/widget.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -418,7 +418,7 @@ def handle_comm_opened(comm, msg):
418418
state = data['state']
419419

420420
# Find the widget class to instantiate in the registered widgets
421-
widget_class = register.get(state['_model_module'],
421+
widget_class = _registry.get(state['_model_module'],
422422
state['_model_module_version'],
423423
state['_model_name'],
424424
state['_view_module'],

0 commit comments

Comments
 (0)