This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author terry.reedy
Recipients gpolo, serhiy.storchaka, terry.reedy, zach.ware
Date 2014-08-20.22:42:56
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
For idle tests, I already avoid the default root and (intend to) create all widgets as a descendent of an explicit root.  This allows explicit deletion and avoidance of error messages and memory leaks. This seems to cover the majority of changes.

An explicit root is mostly true of idle code also, but there seem to be a few exceptions (as indicated by error messages). I presume that deleting and preventing the re-creation of default root, with the code in the patch, would cause a traceback revealing the location of such exceptions. That would have to be done before the offending code is run.

I do not see any need to try to modify the tkinter module for each test function (and slow down tkinter tests). It seems that "tkinter.NoDefaultRoot()" should be moved to destroy_default_root and that function called just once at the top of the module.

Creating and destroying root takes over .04 seconds on my machine.
>>> timeit('root=Tk(); root.destroy()', 'from tkinter import Tk', number=100)
Doing it once per test method, with widgets added, will be noticeable.

Unless a test modifies the root widget itself (other than its set of children), I would rename the AbstractTkinterTest methods to setUpClass and tearDownClass, and leave setUp for regeneration of the specific widget or widgets being tested. That is what we do for Idle gui test classes, and only that often because setUpModule and tearDownModule do not work on 2.7. 

In one module, you have this change:
 # Make sure tkinter._fix runs to set up the environment
+tkinter = support.import_fresh_module('tkinter')

In test/test_idle, I test presence of tkinter with 
  tk = import_module('tkinter')  # imports _tkinter
Perhaps this should use import_fresh_module instead.  Tests seems to work, though there are occasional obscure interaction problems in test suite.
Date User Action Args
2014-08-20 22:42:57terry.reedysetrecipients: + terry.reedy, gpolo, zach.ware, serhiy.storchaka
2014-08-20 22:42:57terry.reedysetmessageid: <>
2014-08-20 22:42:57terry.reedylinkissue22236 messages
2014-08-20 22:42:56terry.reedycreate