Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix registry state lookup #3653

Merged
4 changes: 2 additions & 2 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ jobs:
python -m sphinx -T -E -b html -d ../build/doctrees -D language=en . ../build/html
js:
name: JavaScript
runs-on: ubuntu-latest
# as of #3653 ubuntu-latest wasn't working
runs-on: ubuntu-20.04

steps:
- uses: actions/checkout@v2
Expand All @@ -50,7 +51,6 @@ jobs:
**/requirements*.txt
- name: Install dependencies
run: |
sudo apt-get install -y firefox
python -m pip install --upgrade pip
python -m pip install jupyterlab~=3.0
- name: Install node
Expand Down
19 changes: 5 additions & 14 deletions python/ipywidgets/ipywidgets/widgets/tests/test_send_state.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,29 +12,20 @@
# A widget with simple traits
class SimpleWidget(Widget):
a = Bool().tag(sync=True)
b = Tuple(Bool(), Bool(), Bool(), default_value=(False, False, False)).tag(sync=True)
b = Tuple(Bool(), Bool(), Bool(), default_value=(False, False, False)).tag(
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can i roll these back, too?

sync=True
)
c = List(Bool()).tag(sync=True)


def test_empty_send_state():
w = SimpleWidget()
w.send_state([])
assert w.comm.messages == []


def test_empty_hold_sync():
w = SimpleWidget()
with w.hold_sync():
pass
assert w.comm.messages == []


def test_control():
comm = DummyComm()
Widget.close_all()
w = SimpleWidget()
Widget.handle_control_comm_opened(
comm, dict(metadata={'version': __control_protocol_version__})
)
Widget._handle_control_comm_msg(dict(content=dict(
data={'method': 'request_states'}
)))
assert comm.messages
26 changes: 16 additions & 10 deletions python/ipywidgets/ipywidgets/widgets/tests/test_widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,18 @@

"""Test Widget."""

import inspect

import pytest
from IPython.core.interactiveshell import InteractiveShell
from IPython.display import display
from IPython.utils.capture import capture_output
import inspect
import pytest

from .. import widget
from ..widget import Widget
from ..widget_button import Button


def test_no_widget_view():
# ensure IPython shell is instantiated
# otherwise display() just calls print
Expand All @@ -24,10 +26,12 @@ def test_no_widget_view():

assert len(cap.outputs) == 1, "expect 1 output"
mime_bundle = cap.outputs[0].data
assert mime_bundle['text/plain'] == repr(w), "expected plain text output"
assert 'application/vnd.jupyter.widget-view+json' not in mime_bundle, "widget has no view"
assert cap.stdout == '', repr(cap.stdout)
assert cap.stderr == '', repr(cap.stderr)
assert mime_bundle["text/plain"] == repr(w), "expected plain text output"
assert (
"application/vnd.jupyter.widget-view+json" not in mime_bundle
), "widget has no view"
assert cap.stdout == "", repr(cap.stdout)
assert cap.stderr == "", repr(cap.stderr)


def test_widget_view():
Expand All @@ -41,10 +45,12 @@ def test_widget_view():

assert len(cap.outputs) == 1, "expect 1 output"
mime_bundle = cap.outputs[0].data
assert mime_bundle['text/plain'] == repr(w), "expected plain text output"
assert 'application/vnd.jupyter.widget-view+json' in mime_bundle, "widget should have have a view"
assert cap.stdout == '', repr(cap.stdout)
assert cap.stderr == '', repr(cap.stderr)
assert mime_bundle["text/plain"] == repr(w), "expected plain text output"
assert (
"application/vnd.jupyter.widget-view+json" in mime_bundle
), "widget should have have a view"
assert cap.stdout == "", repr(cap.stdout)
assert cap.stderr == "", repr(cap.stderr)


def test_close_all():
Expand Down
2 changes: 1 addition & 1 deletion python/ipywidgets/ipywidgets/widgets/widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -418,7 +418,7 @@ def handle_comm_opened(comm, msg):
state = data['state']

# Find the widget class to instantiate in the registered widgets
widget_class = register.get(state['_model_module'],
widget_class = _registry.get(state['_model_module'],
state['_model_module_version'],
state['_model_name'],
state['_view_module'],
Expand Down