1111from idlelib .idle_test .mock_idle import Func
1212from tkinter import Tk , IntVar , BooleanVar , DISABLED , NORMAL
1313from idlelib import config
14- from idlelib .configdialog import ConfigDialog , idleConf , changes , VarTrace
14+ from idlelib .configdialog import idleConf , changes , tracers
1515
1616# Tests should not depend on fortuitous user configurations.
1717# They must not affect actual user .cfg files.
@@ -35,12 +35,12 @@ def setUpModule():
3535 idleConf .userCfg = testcfg
3636 root = Tk ()
3737 # root.withdraw() # Comment out, see issue 30870
38- dialog = ConfigDialog (root , 'Test' , _utest = True )
38+ dialog = configdialog . ConfigDialog (root , 'Test' , _utest = True )
3939
4040def tearDownModule ():
4141 global root , dialog
4242 idleConf .userCfg = usercfg
43- dialog . remove_var_callbacks ()
43+ tracers . detach ()
4444 del dialog
4545 root .update_idletasks ()
4646 root .destroy ()
@@ -423,14 +423,14 @@ def test_update_help_changes(self):
423423 d .update_help_changes = Func ()
424424
425425
426- class TestVarTrace (unittest .TestCase ):
426+ class VarTraceTest (unittest .TestCase ):
427427
428428 def setUp (self ):
429429 changes .clear ()
430+ tracers .clear ()
430431 self .v1 = IntVar (root )
431432 self .v2 = BooleanVar (root )
432433 self .called = 0
433- self .tracers = VarTrace ()
434434
435435 def tearDown (self ):
436436 del self .v1 , self .v2
@@ -442,11 +442,19 @@ def var_changed_boolean(self, *params):
442442 pass
443443
444444 def test_init (self ):
445- self .assertEqual (self .tracers .untraced , [])
446- self .assertEqual (self .tracers .traced , [])
445+ tracers .__init__ ()
446+ self .assertEqual (tracers .untraced , [])
447+ self .assertEqual (tracers .traced , [])
448+
449+ def test_clear (self ):
450+ tracers .untraced .append (0 )
451+ tracers .traced .append (1 )
452+ tracers .clear ()
453+ self .assertEqual (tracers .untraced , [])
454+ self .assertEqual (tracers .traced , [])
447455
448456 def test_add (self ):
449- tr = self . tracers
457+ tr = tracers
450458 func = Func ()
451459 cb = tr .make_callback = mock .Mock (return_value = func )
452460
@@ -469,8 +477,7 @@ def test_add(self):
469477 del tr .make_callback
470478
471479 def test_make_callback (self ):
472- tr = self .tracers
473- cb = tr .make_callback (self .v1 , ('main' , 'section' , 'option' ))
480+ cb = tracers .make_callback (self .v1 , ('main' , 'section' , 'option' ))
474481 self .assertTrue (callable (cb ))
475482 self .v1 .set (42 )
476483 # Not attached, so set didn't invoke the callback.
@@ -481,7 +488,7 @@ def test_make_callback(self):
481488 self .assertEqual (changes ['main' ]['section' ]['option' ], '42' )
482489
483490 def test_attach_detach (self ):
484- tr = self . tracers
491+ tr = tracers
485492 v1 = tr .add (self .v1 , self .var_changed_increment )
486493 v2 = tr .add (self .v2 , self .var_changed_boolean )
487494 expected = [(v1 , self .var_changed_increment ),
0 commit comments