Skip to content

Commit 0c1dafe

Browse files
author
Alan Fleming
committed
Fix tests that need dummy comm & update yarn.lock.
1 parent 75da2f9 commit 0c1dafe

File tree

5 files changed

+65
-52
lines changed

5 files changed

+65
-52
lines changed

packages/controls/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
"test:unit:ie": "npm run test:unit:default -- --browsers=IE"
3535
},
3636
"dependencies": {
37-
"@jupyter-widgets/base": "^6.0.7",
37+
"@jupyter-widgets/base": "^6.0.8",
3838
"@lumino/algorithm": "^1.9.2 || ^2.0.1",
3939
"@lumino/domutils": "^1.8.1 || ^2.1",
4040
"@lumino/messaging": "^1.10.1 || ^2.0.1",

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

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,14 @@
33

44
from traitlets import Bool, Tuple, List
55

6-
from .utils import setup, teardown, DummyComm
6+
7+
from .utils import dummy_comm_fixture
78

89
from ..widget import Widget
910

1011
from ..._version import __control_protocol_version__
1112

13+
1214
# A widget with simple traits
1315
class SimpleWidget(Widget):
1416
a = Bool().tag(sync=True)
@@ -18,13 +20,13 @@ class SimpleWidget(Widget):
1820
c = List(Bool()).tag(sync=True)
1921

2022

21-
def test_empty_send_state():
23+
def test_empty_send_state(dummy_comm_fixture):
2224
w = SimpleWidget()
2325
w.send_state([])
2426
assert w.comm.messages == []
2527

2628

27-
def test_empty_hold_sync():
29+
def test_empty_hold_sync(dummy_comm_fixture):
2830
w = SimpleWidget()
2931
with w.hold_sync():
3032
pass

python/ipywidgets/ipywidgets/widgets/tests/test_set_state.py

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

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

9-
from .utils import setup, teardown
9+
from .utils import dummy_comm_fixture # noqa: F401
1010

1111
import ipywidgets
1212
from ipywidgets import Widget
@@ -81,7 +81,7 @@ class TruncateDataWidget(SimpleWidget):
8181
# Actual tests:
8282
#
8383

84-
def test_set_state_simple(echo):
84+
def test_set_state_simple(echo, dummy_comm_fixture):
8585
w = SimpleWidget()
8686
w.set_state(dict(
8787
a=True,
@@ -92,7 +92,7 @@ def test_set_state_simple(echo):
9292
assert len(w.comm.messages) == (1 if echo else 0)
9393

9494

95-
def test_set_state_transformer(echo):
95+
def test_set_state_transformer(echo, dummy_comm_fixture):
9696
w = TransformerWidget()
9797
w.set_state(dict(
9898
d=[True, False, True]
@@ -119,7 +119,7 @@ def test_set_state_transformer(echo):
119119
assert w.comm.messages == expected
120120

121121

122-
def test_set_state_data(echo):
122+
def test_set_state_data(echo, dummy_comm_fixture):
123123
w = DataWidget()
124124
data = memoryview(b'x'*30)
125125
w.set_state(dict(
@@ -129,7 +129,7 @@ def test_set_state_data(echo):
129129
assert len(w.comm.messages) == (1 if echo else 0)
130130

131131

132-
def test_set_state_data_truncate(echo):
132+
def test_set_state_data_truncate(echo, dummy_comm_fixture):
133133
w = TruncateDataWidget()
134134
data = memoryview(b'x'*30)
135135
w.set_state(dict(
@@ -153,7 +153,7 @@ def test_set_state_data_truncate(echo):
153153
assert buffers[0] == data[:20].tobytes()
154154

155155

156-
def test_set_state_numbers_int(echo):
156+
def test_set_state_numbers_int(echo, dummy_comm_fixture):
157157
# JS does not differentiate between float/int.
158158
# Instead, it formats exact floats as ints in JSON (1.0 -> '1').
159159

@@ -169,7 +169,7 @@ def test_set_state_numbers_int(echo):
169169
assert len(w.comm.messages) == (1 if echo else 0)
170170

171171

172-
def test_set_state_numbers_float(echo):
172+
def test_set_state_numbers_float(echo, dummy_comm_fixture):
173173
w = NumberWidget()
174174
# Set floats to int-like floats
175175
w.set_state(dict(
@@ -181,7 +181,7 @@ def test_set_state_numbers_float(echo):
181181
assert len(w.comm.messages) == (1 if echo else 0)
182182

183183

184-
def test_set_state_float_to_float(echo):
184+
def test_set_state_float_to_float(echo, dummy_comm_fixture):
185185
w = NumberWidget()
186186
# Set floats to float
187187
w.set_state(dict(
@@ -192,7 +192,7 @@ def test_set_state_float_to_float(echo):
192192
assert len(w.comm.messages) == (1 if echo else 0)
193193

194194

195-
def test_set_state_cint_to_float(echo):
195+
def test_set_state_cint_to_float(echo, dummy_comm_fixture):
196196
w = NumberWidget()
197197

198198
# Set CInt to float
@@ -223,7 +223,7 @@ def _x_test_set_state_int_to_int_like():
223223
assert len(w.comm.messages) == 0
224224

225225

226-
def test_set_state_int_to_float(echo):
226+
def test_set_state_int_to_float(echo, dummy_comm_fixture):
227227
w = NumberWidget()
228228

229229
# Set Int to float
@@ -232,7 +232,7 @@ def test_set_state_int_to_float(echo):
232232
i = 3.5
233233
))
234234

235-
def test_property_lock(echo):
235+
def test_property_lock(echo, dummy_comm_fixture):
236236
# when this widget's value is set to 42, it sets itself to 2, and then back to 42 again (and then stops)
237237
class AnnoyingWidget(Widget):
238238
value = Float().tag(sync=True)
@@ -262,7 +262,7 @@ def _propagate_value(self, change):
262262
calls = []
263263
widget._send.assert_has_calls(calls)
264264

265-
def test_hold_sync(echo):
265+
def test_hold_sync(echo, dummy_comm_fixture):
266266
# when this widget's value is set to 42, it sets the value to 2, and also sets a different trait value
267267
class AnnoyingWidget(Widget):
268268
value = Float().tag(sync=True)
@@ -298,7 +298,7 @@ def _propagate_value(self, change):
298298

299299

300300

301-
def test_echo():
301+
def test_echo(dummy_comm_fixture):
302302
# we always echo values back to the frontend
303303
class ValueWidget(Widget):
304304
value = Float().tag(sync=True)
@@ -319,7 +319,7 @@ class ValueWidget(Widget):
319319
widget._send.assert_has_calls(calls)
320320

321321

322-
def test_echo_single():
322+
def test_echo_single(dummy_comm_fixture):
323323
# we always echo multiple changes back in 1 update
324324
class ValueWidget(Widget):
325325
value = Float().tag(sync=True)
@@ -359,7 +359,7 @@ def _square(self, change):
359359
widget._send.assert_has_calls(calls)
360360

361361

362-
def test_no_echo(echo):
362+
def test_no_echo(dummy_comm_fixture):
363363
# in cases where values coming from the frontend are 'heavy', we might want to opt out
364364
class ValueWidget(Widget):
365365
value = Float().tag(sync=True, echo_update=False)

python/ipywidgets/ipywidgets/widgets/tests/utils.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
# Copyright (c) Jupyter Development Team.
22
# Distributed under the terms of the Modified BSD License.
33

4+
import pytest
5+
46
from ipywidgets import Widget
57
import ipywidgets.widgets.widget
68

@@ -95,3 +97,12 @@ def teardown():
9597

9698
def call_method(method, *args, **kwargs):
9799
method(*args, **kwargs)
100+
101+
102+
@pytest.fixture
103+
def dummy_comm_fixture():
104+
setup()
105+
try:
106+
yield
107+
finally:
108+
teardown()

yarn.lock

Lines changed: 33 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -732,11 +732,11 @@ __metadata:
732732
languageName: node
733733
linkType: hard
734734

735-
"@jupyter-widgets/base-manager@^1.0.8, @jupyter-widgets/base-manager@workspace:packages/base-manager":
735+
"@jupyter-widgets/base-manager@^1.0.9, @jupyter-widgets/base-manager@workspace:packages/base-manager":
736736
version: 0.0.0-use.local
737737
resolution: "@jupyter-widgets/base-manager@workspace:packages/base-manager"
738738
dependencies:
739-
"@jupyter-widgets/base": ^6.0.7
739+
"@jupyter-widgets/base": ^6.0.8
740740
"@jupyterlab/services": ^6.0.0 || ^7.0.0
741741
"@lumino/coreutils": ^1.11.1 || ^2
742742
"@types/base64-js": ^1.2.5
@@ -770,7 +770,7 @@ __metadata:
770770
languageName: unknown
771771
linkType: soft
772772

773-
"@jupyter-widgets/base@^6.0.7, @jupyter-widgets/base@workspace:packages/base":
773+
"@jupyter-widgets/base@^6.0.8, @jupyter-widgets/base@workspace:packages/base":
774774
version: 0.0.0-use.local
775775
resolution: "@jupyter-widgets/base@workspace:packages/base"
776776
dependencies:
@@ -812,11 +812,11 @@ __metadata:
812812
languageName: unknown
813813
linkType: soft
814814

815-
"@jupyter-widgets/controls@^5.0.8, @jupyter-widgets/controls@workspace:packages/controls":
815+
"@jupyter-widgets/controls@^5.0.9, @jupyter-widgets/controls@workspace:packages/controls":
816816
version: 0.0.0-use.local
817817
resolution: "@jupyter-widgets/controls@workspace:packages/controls"
818818
dependencies:
819-
"@jupyter-widgets/base": ^6.0.7
819+
"@jupyter-widgets/base": ^6.0.8
820820
"@jupyterlab/services": ^6.0.0 || ^7.0.0
821821
"@lumino/algorithm": ^1.9.2 || ^2.0.1
822822
"@lumino/domutils": ^1.8.1 || ^2.1
@@ -866,9 +866,9 @@ __metadata:
866866
version: 0.0.0-use.local
867867
resolution: "@jupyter-widgets/example-web1@workspace:examples/web1"
868868
dependencies:
869-
"@jupyter-widgets/base": ^6.0.7
870-
"@jupyter-widgets/base-manager": ^1.0.8
871-
"@jupyter-widgets/controls": ^5.0.8
869+
"@jupyter-widgets/base": ^6.0.8
870+
"@jupyter-widgets/base-manager": ^1.0.9
871+
"@jupyter-widgets/controls": ^5.0.9
872872
chai: ^4.0.0
873873
css-loader: ^6.5.1
874874
karma: ^6.3.3
@@ -887,9 +887,9 @@ __metadata:
887887
version: 0.0.0-use.local
888888
resolution: "@jupyter-widgets/example-web2@workspace:examples/web2"
889889
dependencies:
890-
"@jupyter-widgets/base": ^6.0.7
891-
"@jupyter-widgets/base-manager": ^1.0.8
892-
"@jupyter-widgets/controls": ^5.0.8
890+
"@jupyter-widgets/base": ^6.0.8
891+
"@jupyter-widgets/base-manager": ^1.0.9
892+
"@jupyter-widgets/controls": ^5.0.9
893893
codemirror: ^5.48.0
894894
css-loader: ^6.5.1
895895
font-awesome: ^4.7.0
@@ -902,9 +902,9 @@ __metadata:
902902
version: 0.0.0-use.local
903903
resolution: "@jupyter-widgets/example-web3@workspace:examples/web3"
904904
dependencies:
905-
"@jupyter-widgets/base": ^6.0.7
906-
"@jupyter-widgets/controls": ^5.0.8
907-
"@jupyter-widgets/html-manager": ^1.0.10
905+
"@jupyter-widgets/base": ^6.0.8
906+
"@jupyter-widgets/controls": ^5.0.9
907+
"@jupyter-widgets/html-manager": ^1.0.11
908908
"@jupyterlab/services": ^6.0.0 || ^7.0.0
909909
"@types/codemirror": ^5.60.0
910910
"@types/node": ^17.0.2
@@ -924,24 +924,24 @@ __metadata:
924924
version: 0.0.0-use.local
925925
resolution: "@jupyter-widgets/example-web4@workspace:examples/web4"
926926
dependencies:
927-
"@jupyter-widgets/html-manager": ^1.0.10
927+
"@jupyter-widgets/html-manager": ^1.0.11
928928
css-loader: ^6.5.1
929929
font-awesome: ^4.7.0
930930
style-loader: ^3.3.1
931931
webpack: ^5.65.0
932932
languageName: unknown
933933
linkType: soft
934934

935-
"@jupyter-widgets/html-manager@^1.0.10, @jupyter-widgets/html-manager@workspace:packages/html-manager":
935+
"@jupyter-widgets/html-manager@^1.0.11, @jupyter-widgets/html-manager@workspace:packages/html-manager":
936936
version: 0.0.0-use.local
937937
resolution: "@jupyter-widgets/html-manager@workspace:packages/html-manager"
938938
dependencies:
939939
"@fortawesome/fontawesome-free": ^5.12.0
940-
"@jupyter-widgets/base": ^6.0.7
941-
"@jupyter-widgets/base-manager": ^1.0.8
942-
"@jupyter-widgets/controls": ^5.0.8
943-
"@jupyter-widgets/output": ^6.0.7
944-
"@jupyter-widgets/schema": ^0.5.4
940+
"@jupyter-widgets/base": ^6.0.8
941+
"@jupyter-widgets/base-manager": ^1.0.9
942+
"@jupyter-widgets/controls": ^5.0.9
943+
"@jupyter-widgets/output": ^6.0.8
944+
"@jupyter-widgets/schema": ^0.5.5
945945
"@jupyterlab/outputarea": ^3.0.0 || ^4.0.0
946946
"@jupyterlab/rendermime": ^3.0.0 || ^4.0.0
947947
"@jupyterlab/rendermime-interfaces": ^3.0.0 || ^4.0.0
@@ -978,10 +978,10 @@ __metadata:
978978
version: 0.0.0-use.local
979979
resolution: "@jupyter-widgets/jupyterlab-manager@workspace:python/jupyterlab_widgets"
980980
dependencies:
981-
"@jupyter-widgets/base": ^6.0.7
982-
"@jupyter-widgets/base-manager": ^1.0.8
983-
"@jupyter-widgets/controls": ^5.0.8
984-
"@jupyter-widgets/output": ^6.0.7
981+
"@jupyter-widgets/base": ^6.0.8
982+
"@jupyter-widgets/base-manager": ^1.0.9
983+
"@jupyter-widgets/controls": ^5.0.9
984+
"@jupyter-widgets/output": ^6.0.8
985985
"@jupyterlab/application": ^3.0.0 || ^4.0.0
986986
"@jupyterlab/apputils": ^3.0.0 || ^4.0.0
987987
"@jupyterlab/builder": ^3.0.0 || ^4.0.0
@@ -1034,11 +1034,11 @@ __metadata:
10341034
version: 0.0.0-use.local
10351035
resolution: "@jupyter-widgets/notebook-manager@workspace:python/widgetsnbextension"
10361036
dependencies:
1037-
"@jupyter-widgets/base": ^6.0.7
1038-
"@jupyter-widgets/base-manager": ^1.0.8
1039-
"@jupyter-widgets/controls": ^5.0.8
1040-
"@jupyter-widgets/html-manager": ^1.0.10
1041-
"@jupyter-widgets/output": ^6.0.7
1037+
"@jupyter-widgets/base": ^6.0.8
1038+
"@jupyter-widgets/base-manager": ^1.0.9
1039+
"@jupyter-widgets/controls": ^5.0.9
1040+
"@jupyter-widgets/html-manager": ^1.0.11
1041+
"@jupyter-widgets/output": ^6.0.8
10421042
"@jupyterlab/services": ^6.0.0 || ^7.0.0
10431043
"@lumino/messaging": ^1.10.1 || ^2.0.1
10441044
"@lumino/widgets": ^1.30.0 || ^2.1
@@ -1052,17 +1052,17 @@ __metadata:
10521052
languageName: unknown
10531053
linkType: soft
10541054

1055-
"@jupyter-widgets/output@^6.0.7, @jupyter-widgets/output@workspace:packages/output":
1055+
"@jupyter-widgets/output@^6.0.8, @jupyter-widgets/output@workspace:packages/output":
10561056
version: 0.0.0-use.local
10571057
resolution: "@jupyter-widgets/output@workspace:packages/output"
10581058
dependencies:
1059-
"@jupyter-widgets/base": ^6.0.7
1059+
"@jupyter-widgets/base": ^6.0.8
10601060
rimraf: ^3.0.2
10611061
typescript: ~4.9.4
10621062
languageName: unknown
10631063
linkType: soft
10641064

1065-
"@jupyter-widgets/schema@^0.5.4, @jupyter-widgets/schema@workspace:packages/schema":
1065+
"@jupyter-widgets/schema@^0.5.5, @jupyter-widgets/schema@workspace:packages/schema":
10661066
version: 0.0.0-use.local
10671067
resolution: "@jupyter-widgets/schema@workspace:packages/schema"
10681068
languageName: unknown

0 commit comments

Comments
 (0)