Home | History | Annotate | Download | only in idle_test
      1 "Test window, coverage 47%."
      2 
      3 from idlelib import window
      4 import unittest
      5 from test.support import requires
      6 from tkinter import Tk
      7 
      8 
      9 class 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 
     19 class 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 
     44 if __name__ == '__main__':
     45     unittest.main(verbosity=2)
     46