Skip to content

Commit

Permalink
Debug
Browse files Browse the repository at this point in the history
  • Loading branch information
martinRenou committed Oct 21, 2024
1 parent 25b2fc3 commit 5d4e091
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 27 deletions.
2 changes: 1 addition & 1 deletion ipywidgets/widgets/tests/test_interaction.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
# Utility stuff
#-----------------------------------------------------------------------------

from .utils import setup, teardown
from .utils import setup

def f(**kwargs):
pass
Expand Down
2 changes: 1 addition & 1 deletion ipywidgets/widgets/tests/test_link.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import pytest

from .. import jslink, jsdlink, ToggleButton
from .utils import setup, teardown
from .utils import setup

def test_jslink_args():
with pytest.raises(TypeError):
Expand Down
21 changes: 6 additions & 15 deletions ipywidgets/widgets/tests/test_send_state.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

from traitlets import Bool, Tuple, List

from .utils import setup, teardown, DummyComm
from .utils import setup

from ..widget import Widget

Expand All @@ -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(
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
2 changes: 1 addition & 1 deletion ipywidgets/widgets/tests/test_set_state.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

from traitlets import Bool, Tuple, List, Instance, CFloat, CInt, Float, Int, TraitError, observe

from .utils import setup, teardown
from .utils import setup

import ipywidgets
from ipywidgets import Widget
Expand Down
16 changes: 7 additions & 9 deletions ipywidgets/widgets/tests/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
NEW_COMM_PACKAGE = False

import ipykernel.comm

import pytest

class DummyComm():
comm_id = 'a-b-c-d'
Expand All @@ -34,18 +34,13 @@ def send(self, *args, **kwargs):
def close(self, *args, **kwargs):
pass

class DummyCommManager():

def unregister_comm(self, comm):
pass


def dummy_create_comm(**kwargs):
return DummyComm()


def dummy_get_comm_manager(**kwargs):
return DummyCommManager()
return {}


_widget_attrs = {}
Expand Down Expand Up @@ -92,8 +87,11 @@ def teardown_test_comm():
setattr(Widget, attr, value)
_widget_attrs.clear()

@pytest.fixture(autouse=True)
def setup():
setup_test_comm()

def teardown():
yield
teardown_test_comm()

def call_method(method, *args, **kwargs):
method(*args, **kwargs)

0 comments on commit 5d4e091

Please sign in to comment.