Coverage for idle_test/test_window.py: 68%

28 statements  

« prev     ^ index     » next       coverage.py v7.2.5, created at 2023-05-11 13:22 -0700

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() 1b

13 self.assertEqual(wl.dict, {}) 1b

14 self.assertEqual(wl.callbacks, []) 1b

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__': 44 ↛ 45line 44 didn't jump to line 45, because the condition on line 44 was never true

45 unittest.main(verbosity=2)