]> granicus.if.org Git - python/commitdiff
Issue #20567: Delete class attribute gui widgets in idle tests.
authorTerry Jan Reedy <tjreedy@udel.edu>
Thu, 27 Feb 2014 23:47:23 +0000 (18:47 -0500)
committerTerry Jan Reedy <tjreedy@udel.edu>
Thu, 27 Feb 2014 23:47:23 +0000 (18:47 -0500)
Code patch by Serhiy Storchaka

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

index d0dde2505cad3e162d5bc2e2690fbff9218dc633..6b924831930fda5e64054e54be2cb30d524ca33e 100644 (file)
@@ -41,9 +41,10 @@ idle class. For the benefit of buildbot machines that do not have a graphics
 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 @@ so it can be properly destroyed in the corresponding tearDown.
     @classmethod
     def tearDownClass(cls):
         cls.root.destroy()
+        del cls.root
 ---
 
 Support.requires('gui') returns true if it is either called in a main module
index 7d7affc81ce8e995d8cde5f29aa03806c02d4133..eed22869f07b57f56430ebc8a3754856cc5db609 100644 (file)
@@ -277,6 +277,9 @@ class FormatEventTest(unittest.TestCase):
     @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")
index c15a9266d77fa525175aebf8b164326630c93a5b..dc6bb3298dd9448ea1ad16b933d8ab27f9b8f719 100644 (file)
@@ -80,6 +80,7 @@ class FetchTest(unittest.TestCase):
     @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
index e5e720de956b2209ef9df9b4dfbfc40440c9b7ab..2525a135c2ec9c3a4aa3ed9ae10097c25e39cd10 100644 (file)
@@ -64,6 +64,7 @@ class GetSelectionTest(unittest.TestCase):
 ##    @classmethod
 ##    def tearDownClass(cls):
 ##        cls.root.destroy()
+##        del cls.root
 
     def test_get_selection(self):
         # text = Text(master=self.root)
@@ -219,6 +220,7 @@ class SearchTest(unittest.TestCase):
 ##    @classmethod
 ##    def tearDownClass(cls):
 ##        cls.root.destroy()
+##        del cls.root
 
     def test_search(self):
         Equal = self.assertEqual
@@ -261,6 +263,7 @@ class ForwardBackwardTest(unittest.TestCase):
 ##    @classmethod
 ##    def tearDownClass(cls):
 ##        cls.root.destroy()
+##        del cls.root
 
     @classmethod
     def setUpClass(cls):
index 3a0705b943c34a4dc5bee416036438e13e456450..f0b9b762f1c05a3d6e8a99523b3eeeeb9c43d9c6 100644 (file)
@@ -221,6 +221,7 @@ class TkTextTest(TextTest, unittest.TestCase):
     @classmethod
     def tearDownClass(cls):
         cls.root.destroy()
+        del cls.root
 
 
 if __name__ == '__main__':
index 07f45c6999ceb760d55f045ee0ef1f3dd03d4f6c..495b4160f2c0291fbc5f95879280fd28bcf820f8 100644 (file)
@@ -14,6 +14,7 @@ if use_resources and 'gui' in use_resources:
     try:
         root = tk.Tk()
         root.destroy()
+        del root
     except tk.TclError:
         while 'gui' in use_resources:
             use_resources.remove('gui')