Skip to content

Commit 3b2a8b1

Browse files
committed
Add tests for deprecation warnings and the deprecation function
1 parent f83d6e0 commit 3b2a8b1

File tree

3 files changed

+44
-1
lines changed

3 files changed

+44
-1
lines changed
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Copyright (c) Jupyter Development Team.
2+
# Distributed under the terms of the Modified BSD License.
3+
4+
import pytest
5+
from ipywidgets import Button
6+
7+
def test_deprecation_fa_icons():
8+
with pytest.deprecated_call():
9+
Button(icon='fa-home')
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Copyright (c) Jupyter Development Team.
2+
# Distributed under the terms of the Modified BSD License.
3+
4+
import pytest
5+
6+
from ..utils import deprecation
7+
8+
def test_deprecation():
9+
with pytest.deprecated_call() as w:
10+
deprecation('Deprecated call')
11+
# Make sure the deprecation pointed to the external function calling this test function
12+
assert w[0].filename.endswith('_pytest/python.py')
13+
14+
with pytest.deprecated_call() as w:
15+
deprecation('Deprecated call', ['ipywidgets/widgets/tests'])
16+
# Make sure the deprecation pointed to the external function calling this test function
17+
assert w[0].filename.endswith('_pytest/python.py')

python/ipywidgets/ipywidgets/widgets/tests/test_widget_string.py

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

4-
from ..widget_string import Combobox
4+
from ..widget_string import Combobox, Text
5+
import pytest
56

67

78
def test_combobox_creation_blank():
@@ -32,3 +33,19 @@ def test_combobox_creation_kwargs():
3233
"Vanilla",
3334
)
3435
assert w.ensure_option == True
36+
37+
def test_deprecation_description_tooltip():
38+
with pytest.deprecated_call():
39+
Text(description_tooltip='tooltip')
40+
41+
with pytest.deprecated_call():
42+
Text().description_tooltip
43+
44+
45+
with pytest.deprecated_call():
46+
Text().description_tooltip = 'tooltip'
47+
48+
49+
def test_deprecation_on_submit():
50+
with pytest.deprecated_call():
51+
Text().on_submit(lambda *args: ...)

0 commit comments

Comments
 (0)