File tree Expand file tree Collapse file tree 1 file changed +17
-13
lines changed
Expand file tree Collapse file tree 1 file changed +17
-13
lines changed Original file line number Diff line number Diff line change @@ -254,25 +254,29 @@ def test_CheckButtons():
254254 check .disconnect (cid )
255255
256256
257- def check_TextBox ():
258- def submit (text ):
259- tool .set_val ('x**1' )
260-
261- def change (text ):
262- tool .color = '1.0'
257+ def test_TextBox ():
258+ from unittest .mock import Mock
259+ submit_event = Mock ()
260+ text_change_event = Mock ()
263261 ax = get_ax ()
264- tool = widgets .TextBox (ax , 'Evaluate' , color = '.95' , initial = 'x**2' )
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+
265268 assert tool .text == 'x**2'
266- tool . on_submit ( submit )
267- tool . on_text_change ( change )
269+ assert text_change_event . call_count == 1
270+
268271 tool .begin_typing (tool .text )
269272 tool .stop_typing ()
270- assert tool .text == 'x**1'
271- assert tool .color == '1.0'
272273
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' )
273278
274- def test_TextBox ():
275- check_TextBox ()
279+ assert text_change_event .call_count == 3
276280
277281
278282@image_comparison (['check_radio_buttons.png' ], style = 'mpl20' , remove_text = True )
You can’t perform that action at this time.
0 commit comments