1"Test window, coverage 47%." 2 3from idlelib import window 4import unittest 5from test.support import requires 6from tkinter import Tk 7 8 9class WindowListTest(unittest.TestCase): 10 11 def test_init(self): 12 wl = window.WindowList() 13 self.assertEqual(wl.dict, {}) 14 self.assertEqual(wl.callbacks, []) 15 16 # Further tests need mock Window. 17 18 19class ListedToplevelTest(unittest.TestCase): 20 21 @classmethod 22 def setUpClass(cls): 23 window.registry = set() 24 requires('gui') 25 cls.root = Tk() 26 cls.root.withdraw() 27 28 @classmethod 29 def tearDownClass(cls): 30 window.registry = window.WindowList() 31 cls.root.update_idletasks() 32## for id in cls.root.tk.call('after', 'info'): 33## cls.root.after_cancel(id) # Need for EditorWindow. 34 cls.root.destroy() 35 del cls.root 36 37 def test_init(self): 38 39 win = window.ListedToplevel(self.root) 40 self.assertIn(win, window.registry) 41 self.assertEqual(win.focused_widget, win) 42 43 44if __name__ == '__main__': 45 unittest.main(verbosity=2) 46