Issue #27922: IDLE tests no longer flash tk widgets (Merge 3.5).

This commit is contained in:
Terry Jan Reedy 2016-08-31 21:09:02 -04:00
commit 5f30f79357
9 changed files with 21 additions and 6 deletions

View file

@ -20,15 +20,16 @@ from idlelib.idle_test.mock_tk import Mbox_func
def setUpModule():
global root
root = Tk()
root.withdraw()
def tearDownModule():
global root
root.update_idletasks()
root.destroy() # pyflakes falsely sees root as undefined
root.destroy() # Pyflakes falsely sees root as undefined.
del root
class TV(tv.TextViewer): # used by TextViewTest
class TV(tv.TextViewer): # Used in TextViewTest.
transient = Func()
grab_set = Func()
wait_window = Func()
@ -59,8 +60,8 @@ class TextViewTest(unittest.TestCase):
view.destroy = Func()
view.Ok()
self.assertTrue(view.destroy.called)
del view.destroy # unmask real function
view.destroy
del view.destroy # Unmask real function.
view.destroy()
class ViewFunctionTest(unittest.TestCase):
@ -76,9 +77,10 @@ class ViewFunctionTest(unittest.TestCase):
del cls.orig_error
def test_view_text(self):
# If modal True, tkinter will error with 'can't invoke "event" command'
# If modal True, get tk error 'can't invoke "event" command'.
view = tv.view_text(root, 'Title', 'test text', modal=False)
self.assertIsInstance(view, tv.TextViewer)
view.Ok()
def test_view_file(self):
test_dir = os.path.dirname(__file__)
@ -88,7 +90,7 @@ class ViewFunctionTest(unittest.TestCase):
self.assertIn('Test', view.textView.get('1.0', '1.end'))
view.Ok()
# Mock showerror will be used and view_file will return None
# Mock showerror will be used; view_file will return None.
testfile = os.path.join(test_dir, '../notthere.py')
view = tv.view_file(root, 'Title', testfile, modal=False)
self.assertIsNone(view)