MCPcopy Index your code
hub / github.com/matplotlib/matplotlib / test_TextBox

Function test_TextBox

lib/matplotlib/tests/test_widgets.py:1070–1098  ·  view source on GitHub ↗
(ax, toolbar)

Source from the content-addressed store, hash-verified

1068
1069@pytest.mark.parametrize("toolbar", ["none", "toolbar2", "toolmanager"])
1070def test_TextBox(ax, toolbar):
1071 # Avoid "toolmanager is provisional" warning.
1072 plt.rcParams._set("toolbar", toolbar)
1073
1074 submit_event = mock.Mock(spec=noop, return_value=None)
1075 text_change_event = mock.Mock(spec=noop, return_value=None)
1076 tool = widgets.TextBox(ax, '')
1077 tool.on_submit(submit_event)
1078 tool.on_text_change(text_change_event)
1079
1080 assert tool.text == ''
1081
1082 MouseEvent._from_ax_coords("button_press_event", ax, (.5, .5), 1)._process()
1083
1084 tool.set_val('x**2')
1085
1086 assert tool.text == 'x**2'
1087 assert text_change_event.call_count == 1
1088
1089 tool.begin_typing()
1090 tool.stop_typing()
1091
1092 assert submit_event.call_count == 2
1093
1094 MouseEvent._from_ax_coords("button_press_event", ax, (.5, .5), 1)._process()
1095 KeyEvent("key_press_event", ax.figure.canvas, "+")._process()
1096 KeyEvent("key_press_event", ax.figure.canvas, "5")._process()
1097
1098 assert text_change_event.call_count == 3
1099
1100
1101def test_RadioButtons(ax):

Callers

nothing calls this directly

Calls 9

on_submitMethod · 0.95
on_text_changeMethod · 0.95
set_valMethod · 0.95
begin_typingMethod · 0.95
stop_typingMethod · 0.95
KeyEventClass · 0.90
_setMethod · 0.80
_processMethod · 0.80
_from_ax_coordsMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…