diff -r 4c5f7b61b6c5 Lib/idlelib/idle_test/htest.py --- a/Lib/idlelib/idle_test/htest.py Sun Jun 19 18:32:07 2016 +0300 +++ b/Lib/idlelib/idle_test/htest.py Mon Jun 20 05:00:07 2016 -0400 @@ -364,7 +364,7 @@ test = getattr(mod, test_name) test_list.append((test_spec, test)) - test_name = tk.StringVar('') + test_name = tk.StringVar(root) callable_object = None test_kwds = None diff -r 4c5f7b61b6c5 Lib/idlelib/idle_test/test_searchbase.py --- a/Lib/idlelib/idle_test/test_searchbase.py Sun Jun 19 18:32:07 2016 +0300 +++ b/Lib/idlelib/idle_test/test_searchbase.py Mon Jun 20 05:00:07 2016 -0400 @@ -74,7 +74,7 @@ def test_make_entry(self): equal = self.assertEqual self.dialog.row = 0 - self.dialog.top = Toplevel(self.root) + self.dialog.top = self.root entry, label = self.dialog.make_entry("Test:", 'hello') equal(label['text'], 'Test:') @@ -87,6 +87,7 @@ equal(self.dialog.row, 1) def test_create_entries(self): + self.dialog.top = self.root self.dialog.row = 0 self.engine.setpat('hello') self.dialog.create_entries() @@ -94,7 +95,7 @@ def test_make_frame(self): self.dialog.row = 0 - self.dialog.top = Toplevel(self.root) + self.dialog.top = self.root frame, label = self.dialog.make_frame() self.assertEqual(label, '') self.assertIsInstance(frame, Frame) @@ -104,7 +105,7 @@ self.assertIsInstance(frame, Frame) def btn_test_setup(self, meth): - self.dialog.top = Toplevel(self.root) + self.dialog.top = self.root self.dialog.row = 0 return meth() @@ -145,12 +146,13 @@ self.assertEqual(var.get(), state) def test_make_button(self): - self.dialog.top = Toplevel(self.root) + self.dialog.top = self.root self.dialog.buttonframe = Frame(self.dialog.top) btn = self.dialog.make_button('Test', self.dialog.close) self.assertEqual(btn['text'], 'Test') def test_create_command_buttons(self): + self.dialog.top = self.root self.dialog.create_command_buttons() # Look for close button command in buttonframe closebuttoncommand = '' diff -r 4c5f7b61b6c5 Lib/idlelib/idle_test/test_text.py --- a/Lib/idlelib/idle_test/test_text.py Sun Jun 19 18:32:07 2016 +0300 +++ b/Lib/idlelib/idle_test/test_text.py Mon Jun 20 05:00:07 2016 -0400 @@ -1,17 +1,19 @@ -# Test mock_tk.Text class against tkinter.Text class by running same tests with both. +''' Test mock_tk.Text class against tkinter.Text class + +Run same tests with both by creating a mixin class. +''' import unittest from test.support import requires - from _tkinter import TclError class TextTest(object): + "Define items common to both sets of tests." - hw = 'hello\nworld' # usual initial insert after initialization + hw = 'hello\nworld' # Several tests insert this after after initialization. hwn = hw+'\n' # \n present at initialization, before insert - Text = None - def setUp(self): - self.text = self.Text() + # setUpClass defines cls.Text and maybe cls.root. + # setUp defines self.text from Text and maybe root. def test_init(self): self.assertEqual(self.text.get('1.0'), '\n') @@ -196,6 +198,10 @@ from idlelib.idle_test.mock_tk import Text cls.Text = Text + def setUp(self): + self.text = self.Text() + + def test_decode(self): # test endflags (-1, 0) not tested by test_index (which uses +1) decode = self.text._decode @@ -222,6 +228,9 @@ cls.root.destroy() del cls.root + def setUp(self): + self.text = self.Text(self.root) + if __name__ == '__main__': unittest.main(verbosity=2, exit=False) diff -r 4c5f7b61b6c5 Lib/idlelib/percolator.py --- a/Lib/idlelib/percolator.py Sun Jun 19 18:32:07 2016 +0300 +++ b/Lib/idlelib/percolator.py Mon Jun 20 05:00:07 2016 -0400 @@ -89,10 +89,10 @@ (pin if var2.get() else pout)(t2) text.pack() - var1 = tk.IntVar() + var1 = tk.IntVar(parent) cb1 = tk.Checkbutton(box, text="Tracer1", command=toggle1, variable=var1) cb1.pack() - var2 = tk.IntVar() + var2 = tk.IntVar(parent) cb2 = tk.Checkbutton(box, text="Tracer2", command=toggle2, variable=var2) cb2.pack() diff -r 4c5f7b61b6c5 Lib/idlelib/pyshell.py --- a/Lib/idlelib/pyshell.py Sun Jun 19 18:32:07 2016 +0300 +++ b/Lib/idlelib/pyshell.py Mon Jun 20 05:00:07 2016 -0400 @@ -2,6 +2,7 @@ try: from tkinter import * + # NoDefaultRoot() # More testing is needed for permanent uncomment. except ImportError: print("** IDLE can't import Tkinter.\n" "Your Python may not be configured for Tk. **", file=sys.__stderr__) diff -r 4c5f7b61b6c5 Lib/test/test_idle.py --- a/Lib/test/test_idle.py Sun Jun 19 18:32:07 2016 +0300 +++ b/Lib/test/test_idle.py Mon Jun 20 05:00:07 2016 -0400 @@ -6,6 +6,7 @@ tk = import_module('tkinter') # imports _tkinter if tk.TkVersion < 8.5: raise unittest.SkipTest("IDLE requires tk 8.5 or later.") +tk.NoDefaultRoot() idletest = import_module('idlelib.idle_test') # Without test_main present, regrtest.runtest_inner (line1219) calls