Skip to content

Commit 4aff0cd

Browse files
author
Alan
committed
Simplify tests (some were failing for an unknown reason when run together).
1 parent 1833ca0 commit 4aff0cd

File tree

5 files changed

+15
-45
lines changed

5 files changed

+15
-45
lines changed

.github/workflows/packaging.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ jobs:
8383
fail-fast: false
8484
matrix:
8585
os: [ubuntu, windows]
86-
python: ['3.9', '3.13']
86+
python: ['3.10', '3.13']
8787
dist: ['ipywidgets*.tar.gz']
8888
include:
8989
- python: '3.13'

.github/workflows/tests.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ jobs:
7777
strategy:
7878
max-parallel: 4
7979
matrix:
80-
python-version: ['3.9', '3.10', '3.11', '3.12', '3.13']
80+
python-version: ['3.10', '3.11', '3.12', '3.13', '3.14']
8181

8282
steps:
8383
- uses: actions/checkout@v4
@@ -96,7 +96,7 @@ jobs:
9696
pip install file://$PWD/python/ipywidgets#egg=ipywidgets[test]
9797
- name: Test with pytest
9898
run: |
99-
pip install "pytest<8"
99+
pip install "pytest"
100100
cd python/ipywidgets
101101
pytest --cov=ipywidgets ipywidgets
102102

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

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -159,33 +159,28 @@ def test_widget_open():
159159
"Widget",
160160
],
161161
)
162-
@pytest.mark.parametrize("enable_weakref", [True, False])
163-
def test_weakreference(class_name, enable_weakref):
162+
def test_weakreference(class_name):
164163
# Ensure the base instance of all widgets can be deleted / garbage collected.
165-
if enable_weakref:
166-
ipw.enable_weakreference()
167-
cls = getattr(ipw, class_name)
168-
if class_name in ['SelectionRangeSlider', 'SelectionSlider']:
169-
kwgs = {"options": [1, 2, 4]}
170-
else:
171-
kwgs = {}
164+
ipw.enable_weakreference()
172165
try:
173-
w = cls(**kwgs)
166+
cls = getattr(ipw, class_name)
167+
if class_name in ["SelectionRangeSlider", "SelectionSlider"]:
168+
kwgs = {"options": [1, 2, 4]}
169+
else:
170+
kwgs = {}
171+
w: Widget = cls(**kwgs)
174172
deleted = False
175173
def on_delete():
176174
nonlocal deleted
177175
deleted = True
178176
weakref.finalize(w, on_delete)
179177
# w should be the only strong ref to the widget.
180178
# calling `del` should invoke its immediate deletion calling the `__del__` method.
181-
if not enable_weakref:
182-
w.close()
183179
del w
184180
gc.collect()
185181
assert deleted
186182
finally:
187-
if enable_weakref:
188-
ipw.disable_weakreference()
183+
ipw.disable_weakreference()
189184

190185

191186
@pytest.mark.parametrize("weakref_enabled", [True, False])

python/ipywidgets/ipywidgets/widgets/tests/test_widget_box.py

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -55,29 +55,3 @@ def test_box_validate_mode():
5555
with pytest.raises(TraitError):
5656
box.children += ("Not a widget", closed_button)
5757

58-
59-
def test_box_gc():
60-
widgets.enable_weakreference()
61-
# Test Box gc collected and children lifecycle managed.
62-
try:
63-
deleted = False
64-
65-
class TestButton(widgets.Button):
66-
def my_click(self, b):
67-
pass
68-
69-
button = TestButton(description="button")
70-
button.on_click(button.my_click)
71-
72-
b = widgets.VBox(children=[button])
73-
74-
def on_delete():
75-
nonlocal deleted
76-
deleted = True
77-
78-
weakref.finalize(b, on_delete)
79-
del b
80-
gc.collect()
81-
assert deleted
82-
finally:
83-
widgets.disable_weakreference()

python/ipywidgets/setup.cfg

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,16 +18,16 @@ classifiers =
1818
License :: OSI Approved :: BSD License
1919
Programming Language :: Python
2020
Programming Language :: Python :: 3
21-
Programming Language :: Python :: 3.9
2221
Programming Language :: Python :: 3.10
2322
Programming Language :: Python :: 3.11
2423
Programming Language :: Python :: 3.12
2524
Programming Language :: Python :: 3.13
25+
Programming Language :: Python :: 3.14
2626
Programming Language :: Python :: 3 :: Only
2727
Framework :: Jupyter
2828

2929
[options]
30-
python_requires = >=3.7
30+
python_requires = >=3.10
3131

3232
zip_safe = False
3333
# include_package_data = True
@@ -47,6 +47,7 @@ test =
4747
pytest>=3.6.0
4848
pytest-cov
4949
pytz
50+
pytest-mock
5051

5152
[options.package_data]
5253
ipywidgets =

0 commit comments

Comments
 (0)