changeset: 89419:daf44eb9c54e branch: 3.3 parent: 89416:b3fb7828b6fc user: Terry Jan Reedy date: Thu Feb 27 18:47:49 2014 -0500 files: Lib/idlelib/idle_test/README.txt Lib/idlelib/idle_test/test_formatparagraph.py Lib/idlelib/idle_test/test_idlehistory.py Lib/idlelib/idle_test/test_searchengine.py Lib/idlelib/idle_test/test_text.py Lib/test/test_idle.py description: Issue #20567: Delete class attribute gui widgets in idle tests. Code patch by Serhiy Storchaka diff -r b3fb7828b6fc -r daf44eb9c54e Lib/idlelib/idle_test/README.txt --- a/Lib/idlelib/idle_test/README.txt Thu Feb 27 22:14:31 2014 +0100 +++ b/Lib/idlelib/idle_test/README.txt Thu Feb 27 18:47:49 2014 -0500 @@ -41,9 +41,10 @@ screen, gui tests must be 'guarded' by "requires('gui')" in a setUp function or method. This will typically be setUpClass. -All gui objects must be destroyed by the end of the test, perhaps in a tearDown -function. Creating the Tk root directly in a setUp allows a reference to be saved -so it can be properly destroyed in the corresponding tearDown. +To avoid interfering with other gui tests, all gui objects must be destroyed +and deleted by the end of the test. If a widget, such as a Tk root, is created +in a setUpX function, destroy it in the corresponding tearDownX. For module +and class attributes, also delete the widget. --- @classmethod def setUpClass(cls): @@ -53,6 +54,7 @@ @classmethod def tearDownClass(cls): cls.root.destroy() + del cls.root --- Support.requires('gui') returns true if it is either called in a main module diff -r b3fb7828b6fc -r daf44eb9c54e Lib/idlelib/idle_test/test_formatparagraph.py --- a/Lib/idlelib/idle_test/test_formatparagraph.py Thu Feb 27 22:14:31 2014 +0100 +++ b/Lib/idlelib/idle_test/test_formatparagraph.py Thu Feb 27 18:47:49 2014 -0500 @@ -277,6 +277,9 @@ @classmethod def tearDownClass(cls): cls.root.destroy() + del cls.root + del cls.text + del cls.formatter def test_short_line(self): self.text.insert('1.0', "Short line\n") diff -r b3fb7828b6fc -r daf44eb9c54e Lib/idlelib/idle_test/test_idlehistory.py --- a/Lib/idlelib/idle_test/test_idlehistory.py Thu Feb 27 22:14:31 2014 +0100 +++ b/Lib/idlelib/idle_test/test_idlehistory.py Thu Feb 27 18:47:49 2014 -0500 @@ -80,6 +80,7 @@ @classmethod def tearDownClass(cls): cls.root.destroy() + del cls.root def fetch_test(self, reverse, line, prefix, index, *, bell=False): # Perform one fetch as invoked by Alt-N or Alt-P diff -r b3fb7828b6fc -r daf44eb9c54e Lib/idlelib/idle_test/test_searchengine.py --- a/Lib/idlelib/idle_test/test_searchengine.py Thu Feb 27 22:14:31 2014 +0100 +++ b/Lib/idlelib/idle_test/test_searchengine.py Thu Feb 27 18:47:49 2014 -0500 @@ -64,6 +64,7 @@ ## @classmethod ## def tearDownClass(cls): ## cls.root.destroy() +## del cls.root def test_get_selection(self): # text = Text(master=self.root) @@ -219,6 +220,7 @@ ## @classmethod ## def tearDownClass(cls): ## cls.root.destroy() +## del cls.root def test_search(self): Equal = self.assertEqual @@ -261,6 +263,7 @@ ## @classmethod ## def tearDownClass(cls): ## cls.root.destroy() +## del cls.root @classmethod def setUpClass(cls): diff -r b3fb7828b6fc -r daf44eb9c54e Lib/idlelib/idle_test/test_text.py --- a/Lib/idlelib/idle_test/test_text.py Thu Feb 27 22:14:31 2014 +0100 +++ b/Lib/idlelib/idle_test/test_text.py Thu Feb 27 18:47:49 2014 -0500 @@ -221,6 +221,7 @@ @classmethod def tearDownClass(cls): cls.root.destroy() + del cls.root if __name__ == '__main__': diff -r b3fb7828b6fc -r daf44eb9c54e Lib/test/test_idle.py --- a/Lib/test/test_idle.py Thu Feb 27 22:14:31 2014 +0100 +++ b/Lib/test/test_idle.py Thu Feb 27 18:47:49 2014 -0500 @@ -14,6 +14,7 @@ try: root = tk.Tk() root.destroy() + del root except tk.TclError: while 'gui' in use_resources: use_resources.remove('gui')