Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 077393e

Browse filesBrowse files
authored
Merge pull request #20451 from dmatos2012/testcov_textbox
Add initial TextBox widget testing
2 parents af17a9b + db72f7f commit 077393e
Copy full SHA for 077393e

File tree

Expand file treeCollapse file tree

1 file changed

+25
-0
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+25
-0
lines changed

‎lib/matplotlib/tests/test_widgets.py

Copy file name to clipboardExpand all lines: lib/matplotlib/tests/test_widgets.py
+25Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,31 @@ def test_CheckButtons():
254254
check.disconnect(cid)
255255

256256

257+
def test_TextBox():
258+
from unittest.mock import Mock
259+
submit_event = Mock()
260+
text_change_event = Mock()
261+
ax = get_ax()
262+
263+
tool = widgets.TextBox(ax, 'Evaluate')
264+
tool.on_submit(submit_event)
265+
tool.on_text_change(text_change_event)
266+
tool.set_val('x**2')
267+
268+
assert tool.text == 'x**2'
269+
assert text_change_event.call_count == 1
270+
271+
tool.begin_typing(tool.text)
272+
tool.stop_typing()
273+
274+
assert submit_event.call_count == 2
275+
do_event(tool, '_click')
276+
do_event(tool, '_keypress', key='+')
277+
do_event(tool, '_keypress', key='5')
278+
279+
assert text_change_event.call_count == 3
280+
281+
257282
@image_comparison(['check_radio_buttons.png'], style='mpl20', remove_text=True)
258283
def test_check_radio_buttons_image():
259284
# Remove this line when this test image is regenerated.

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.