@@ -62,14 +62,15 @@ def test_create(self):
62
62
def test_create_window_creates_underlying_tk_object (self ):
63
63
64
64
w = self ._Window ()
65
- self .assertIsInstance (w ._tk_window , fake_tkinter .FakeTk )
65
+ wrapped_tk_window = self .tkinter .windows [0 ]
66
+ self .assertIsInstance (wrapped_tk_window , fake_tkinter .FakeTk )
66
67
67
68
68
69
def test_default_title_was_set (self ):
69
70
70
71
w = self ._Window ()
71
- tk_window = w . _tk_window
72
- tk_window .title .assert_called_once_with ('A-Turtle' )
72
+ wrapped_tk_window = self . tkinter . windows [ 0 ]
73
+ wrapped_tk_window .title .assert_called_once_with ('A-Turtle' )
73
74
74
75
75
76
def test_default_width (self ):
@@ -134,10 +135,10 @@ def test_resize_handler_in_place(self):
134
135
135
136
w = self ._Window ()
136
137
137
- tk_window = w . _tk_window
138
- tk_window .bind .assert_called_once ()
138
+ wrapped_tk_window = self . tkinter . windows [ 0 ]
139
+ wrapped_tk_window .bind .assert_called_once ()
139
140
140
- (sequence , func ), _kwargs = tk_window .bind .call_args
141
+ (sequence , func ), _kwargs = wrapped_tk_window .bind .call_args
141
142
self .assertEqual (sequence , '<Configure>' )
142
143
self .assertTrue (callable (func ), 'Resize handler not callable.' )
143
144
@@ -207,8 +208,8 @@ def test_custom_fill_passed_to_canvas(self):
207
208
def test_custom_title_passed_to_tk_window (self ):
208
209
209
210
w = self ._Window (title = 'Test Title' )
210
- tk_window = w . _tk_window
211
- tk_window .title .assert_called_once_with ('Test Title' )
211
+ wrapped_tk_window = self . tkinter . windows [ 0 ]
212
+ wrapped_tk_window .title .assert_called_once_with ('Test Title' )
212
213
213
214
214
215
def test_positive_horizontal_placement (self ):
@@ -295,14 +296,15 @@ def setUp(self):
295
296
296
297
super ().setUp ()
297
298
self .w = self ._Window ()
299
+ self .wrapped_tk_window = self .tkinter .windows [0 ]
298
300
299
301
300
302
def test_bind_calls_tk_window_bind (self ):
301
303
302
304
handler = mock .Mock ()
303
305
self .w .bind ('<KeyPress-a>' , handler )
304
306
305
- self .w . _tk_window .bind .assert_called_with ('<KeyPress-a>' , handler )
307
+ self .wrapped_tk_window .bind .assert_called_with ('<KeyPress-a>' , handler )
306
308
307
309
308
310
def test_bind_unbind_calls_tk_window_bind_unbind (self ):
@@ -311,8 +313,8 @@ def test_bind_unbind_calls_tk_window_bind_unbind(self):
311
313
self .w .bind ('<KeyPress-a>' , handler )
312
314
self .w .unbind ('<KeyPress-a>' )
313
315
314
- self .w . _tk_window .bind .assert_called_with ('<KeyPress-a>' , handler )
315
- self .w . _tk_window .unbind .assert_called_with ('<KeyPress-a>' , mock .ANY )
316
+ self .wrapped_tk_window .bind .assert_called_with ('<KeyPress-a>' , handler )
317
+ self .wrapped_tk_window .unbind .assert_called_with ('<KeyPress-a>' , mock .ANY )
316
318
317
319
318
320
def test_unbind_unbound_raises_ValueError (self ):
@@ -324,7 +326,7 @@ def test_unbind_unbound_raises_ValueError(self):
324
326
def test_unbind_default_works_with_no_bindings (self ):
325
327
326
328
self .w .unbind ()
327
- self .w . _tk_window .unbind .assert_not_called ()
329
+ self .wrapped_tk_window .unbind .assert_not_called ()
328
330
329
331
330
332
def test_unbind_default_unbinds_all_bindings (self ):
@@ -333,7 +335,7 @@ def test_unbind_default_unbinds_all_bindings(self):
333
335
self .w .bind ('<KeyPress-b>' , mock .Mock ())
334
336
335
337
self .w .unbind ()
336
- unbind_call_args = self .w . _tk_window .unbind .call_args_list
338
+ unbind_call_args = self .wrapped_tk_window .unbind .call_args_list
337
339
self .assertEqual (len (unbind_call_args ), 2 , 'unbind call count' )
338
340
339
341
@@ -346,11 +348,11 @@ def test_bind_direct_key_with_no_cbs_raises_ValueError(self):
346
348
def test_bind_direct_key_with_press_cb_calls_window_bind_twice (self ):
347
349
348
350
# Ignore any window setup bind calls that may have taken place.
349
- self .w . _tk_window .bind .reset_mock ()
351
+ self .wrapped_tk_window .bind .reset_mock ()
350
352
351
353
self .w .bind_direct_key ('x' , mock .Mock ())
352
354
353
- bind_call_args = self .w . _tk_window .bind .call_args_list
355
+ bind_call_args = self .wrapped_tk_window .bind .call_args_list
354
356
self .assertEqual (len (bind_call_args ), 2 , 'unbind call count' )
355
357
356
358
first_call , second_call = bind_call_args
@@ -361,11 +363,11 @@ def test_bind_direct_key_with_press_cb_calls_window_bind_twice(self):
361
363
def test_bind_direct_key_with_release_cb_calls_window_bind_twice (self ):
362
364
363
365
# Ignore any window setup bind calls that may have taken place.
364
- self .w . _tk_window .bind .reset_mock ()
366
+ self .wrapped_tk_window .bind .reset_mock ()
365
367
366
368
self .w .bind_direct_key ('y' , None , mock .Mock ())
367
369
368
- bind_call_args = self .w . _tk_window .bind .call_args_list
370
+ bind_call_args = self .wrapped_tk_window .bind .call_args_list
369
371
self .assertEqual (len (bind_call_args ), 2 , 'unbind call count' )
370
372
371
373
first_call , second_call = bind_call_args
@@ -376,11 +378,11 @@ def test_bind_direct_key_with_release_cb_calls_window_bind_twice(self):
376
378
def test_bind_direct_key_with_both_cbs_calls_window_bind_twice (self ):
377
379
378
380
# Ignore any window setup bind calls that may have taken place.
379
- self .w . _tk_window .bind .reset_mock ()
381
+ self .wrapped_tk_window .bind .reset_mock ()
380
382
381
383
self .w .bind_direct_key ('z' , mock .Mock (), mock .Mock ())
382
384
383
- bind_call_args = self .w . _tk_window .bind .call_args_list
385
+ bind_call_args = self .wrapped_tk_window .bind .call_args_list
384
386
self .assertEqual (len (bind_call_args ), 2 , 'bind call count' )
385
387
386
388
first_call , second_call = bind_call_args
@@ -391,19 +393,19 @@ def test_bind_direct_key_with_both_cbs_calls_window_bind_twice(self):
391
393
def test_bind_unbind_direct_key_calls_window_bind_unbind_twice (self ):
392
394
393
395
# Ignore any window setup bind calls that may have taken place.
394
- self .w . _tk_window .bind .reset_mock ()
396
+ self .wrapped_tk_window .bind .reset_mock ()
395
397
396
398
self .w .bind_direct_key ('a' , mock .Mock (), mock .Mock ())
397
399
self .w .unbind_direct_key ('a' )
398
400
399
- bind_call_args = self .w . _tk_window .bind .call_args_list
401
+ bind_call_args = self .wrapped_tk_window .bind .call_args_list
400
402
self .assertEqual (len (bind_call_args ), 2 , 'bind call count' )
401
403
402
404
first_call , second_call = bind_call_args
403
405
self .assertEqual (first_call , mock .call ('<KeyPress-a>' , mock .ANY ))
404
406
self .assertEqual (second_call , mock .call ('<KeyRelease-a>' , mock .ANY ))
405
407
406
- unbind_call_args = self .w . _tk_window .unbind .call_args_list
408
+ unbind_call_args = self .wrapped_tk_window .unbind .call_args_list
407
409
self .assertEqual (len (unbind_call_args ), 2 , 'unbind call count' )
408
410
409
411
first_call , second_call = unbind_call_args
@@ -420,7 +422,7 @@ def test_unbind_direct_key_unknown_raises_ValueError(self):
420
422
def test_unbind_direct_key_default_works_with_no_bindings (self ):
421
423
422
424
self .w .unbind_direct_key ()
423
- self .w . _tk_window .unbind .assert_not_called ()
425
+ self .wrapped_tk_window .unbind .assert_not_called ()
424
426
425
427
426
428
def test_unbind_direct_key_default_unbinds_all_direct_keys (self ):
@@ -431,7 +433,7 @@ def test_unbind_direct_key_default_unbinds_all_direct_keys(self):
431
433
self .w .unbind_direct_key ()
432
434
433
435
# Expect 4 unbind calls: KeyPress/KeyRelease for 2 keys.
434
- unbind_call_args = self .w . _tk_window .unbind .call_args_list
436
+ unbind_call_args = self .wrapped_tk_window .unbind .call_args_list
435
437
self .assertEqual (len (unbind_call_args ), 4 , 'unbind call count' )
436
438
437
439
@@ -529,9 +531,10 @@ def test_first_has_underlying_tk_others_have_underlying_toplevels(self):
529
531
w2 = self ._Window ()
530
532
w3 = self ._Window ()
531
533
532
- self .assertIsInstance (w1 ._tk_window , fake_tkinter .FakeTk )
533
- self .assertIsInstance (w2 ._tk_window , fake_tkinter .FakeToplevel )
534
- self .assertIsInstance (w3 ._tk_window , fake_tkinter .FakeToplevel )
534
+ wrapped_tk_windows = self .tkinter .windows
535
+ self .assertIsInstance (wrapped_tk_windows [0 ], fake_tkinter .FakeTk )
536
+ self .assertIsInstance (wrapped_tk_windows [1 ], fake_tkinter .FakeToplevel )
537
+ self .assertIsInstance (wrapped_tk_windows [2 ], fake_tkinter .FakeToplevel )
535
538
536
539
537
540
def test_close_first_window_raises_if_there_are_other_windows (self ):
0 commit comments