@@ -305,15 +305,15 @@ def setUp(self):
305
305
306
306
def test_bind_calls_tk_window_bind (self ):
307
307
308
- handler = lambda e : None
308
+ handler = mock . Mock ()
309
309
self .w .bind ('<KeyPress-a>' , handler )
310
310
311
311
self .w ._tk_window .bind .assert_called_with ('<KeyPress-a>' , handler )
312
312
313
313
314
314
def test_bind_unbind_calls_tk_window_bind_unbind (self ):
315
315
316
- handler = lambda e : None
316
+ handler = mock . Mock ()
317
317
self .w .bind ('<KeyPress-a>' , handler )
318
318
self .w .unbind ('<KeyPress-a>' )
319
319
@@ -335,8 +335,8 @@ def test_unbind_default_works_with_no_bindings(self):
335
335
336
336
def test_unbind_default_unbinds_all_bindings (self ):
337
337
338
- self .w .bind ('<KeyPress-a>' , lambda e : None )
339
- self .w .bind ('<KeyPress-b>' , lambda e : None )
338
+ self .w .bind ('<KeyPress-a>' , mock . Mock () )
339
+ self .w .bind ('<KeyPress-b>' , mock . Mock () )
340
340
341
341
self .w .unbind ()
342
342
unbind_call_args = self .w ._tk_window .unbind .call_args_list
@@ -354,8 +354,7 @@ def test_bind_direct_key_with_press_cb_calls_window_bind_twice(self):
354
354
# Ignore any window setup bind calls that may have taken place.
355
355
self .w ._tk_window .bind .reset_mock ()
356
356
357
- press_cb = lambda e : None
358
- self .w .bind_direct_key ('x' , press_cb )
357
+ self .w .bind_direct_key ('x' , mock .Mock ())
359
358
360
359
bind_call_args = self .w ._tk_window .bind .call_args_list
361
360
self .assertEqual (len (bind_call_args ), 2 , 'unbind call count' )
@@ -370,8 +369,7 @@ def test_bind_direct_key_with_release_cb_calls_window_bind_twice(self):
370
369
# Ignore any window setup bind calls that may have taken place.
371
370
self .w ._tk_window .bind .reset_mock ()
372
371
373
- release_cb = lambda e : None
374
- self .w .bind_direct_key ('y' , None , release_cb )
372
+ self .w .bind_direct_key ('y' , None , mock .Mock ())
375
373
376
374
bind_call_args = self .w ._tk_window .bind .call_args_list
377
375
self .assertEqual (len (bind_call_args ), 2 , 'unbind call count' )
@@ -386,9 +384,7 @@ def test_bind_direct_key_with_both_cbs_calls_window_bind_twice(self):
386
384
# Ignore any window setup bind calls that may have taken place.
387
385
self .w ._tk_window .bind .reset_mock ()
388
386
389
- press_cb = lambda e : None
390
- release_cb = lambda e : None
391
- self .w .bind_direct_key ('z' , press_cb , release_cb )
387
+ self .w .bind_direct_key ('z' , mock .Mock (), mock .Mock ())
392
388
393
389
bind_call_args = self .w ._tk_window .bind .call_args_list
394
390
self .assertEqual (len (bind_call_args ), 2 , 'bind call count' )
@@ -403,9 +399,7 @@ def test_bind_unbind_direct_key_calls_window_bind_unbind_twice(self):
403
399
# Ignore any window setup bind calls that may have taken place.
404
400
self .w ._tk_window .bind .reset_mock ()
405
401
406
- press_cb = lambda e : None
407
- release_cb = lambda e : None
408
- self .w .bind_direct_key ('a' , press_cb , release_cb )
402
+ self .w .bind_direct_key ('a' , mock .Mock (), mock .Mock ())
409
403
self .w .unbind_direct_key ('a' )
410
404
411
405
bind_call_args = self .w ._tk_window .bind .call_args_list
@@ -437,10 +431,8 @@ def test_unbind_direct_key_default_works_with_no_bindings(self):
437
431
438
432
def test_unbind_direct_key_default_unbinds_all_direct_keys (self ):
439
433
440
- press_cb = lambda e : None
441
- release_cb = lambda e : None
442
- self .w .bind_direct_key ('a' , press_cb , release_cb )
443
- self .w .bind_direct_key ('b' , press_cb , release_cb )
434
+ self .w .bind_direct_key ('a' , mock .Mock (), mock .Mock ())
435
+ self .w .bind_direct_key ('b' , mock .Mock (), mock .Mock ())
444
436
445
437
self .w .unbind_direct_key ()
446
438
0 commit comments