2018-06-20 22:25:59 -03:00
|
|
|
"Test window, coverage 47%."
|
2018-06-19 20:12:52 -03:00
|
|
|
|
2018-06-20 22:25:59 -03:00
|
|
|
from idlelib import window
|
2018-06-19 20:12:52 -03:00
|
|
|
import unittest
|
|
|
|
from test.support import requires
|
|
|
|
from tkinter import Tk
|
|
|
|
|
|
|
|
|
|
|
|
class WindowListTest(unittest.TestCase):
|
|
|
|
|
|
|
|
def test_init(self):
|
2018-06-20 22:25:59 -03:00
|
|
|
wl = window.WindowList()
|
2018-06-19 20:12:52 -03:00
|
|
|
self.assertEqual(wl.dict, {})
|
|
|
|
self.assertEqual(wl.callbacks, [])
|
|
|
|
|
|
|
|
# Further tests need mock Window.
|
|
|
|
|
|
|
|
|
|
|
|
class ListedToplevelTest(unittest.TestCase):
|
|
|
|
|
|
|
|
@classmethod
|
|
|
|
def setUpClass(cls):
|
2018-06-20 22:25:59 -03:00
|
|
|
window.registry = set()
|
2018-06-19 20:12:52 -03:00
|
|
|
requires('gui')
|
|
|
|
cls.root = Tk()
|
|
|
|
cls.root.withdraw()
|
|
|
|
|
|
|
|
@classmethod
|
|
|
|
def tearDownClass(cls):
|
2018-06-20 22:25:59 -03:00
|
|
|
window.registry = window.WindowList()
|
2018-06-19 20:12:52 -03:00
|
|
|
cls.root.update_idletasks()
|
|
|
|
## for id in cls.root.tk.call('after', 'info'):
|
|
|
|
## cls.root.after_cancel(id) # Need for EditorWindow.
|
|
|
|
cls.root.destroy()
|
|
|
|
del cls.root
|
|
|
|
|
|
|
|
def test_init(self):
|
|
|
|
|
2018-06-20 22:25:59 -03:00
|
|
|
win = window.ListedToplevel(self.root)
|
|
|
|
self.assertIn(win, window.registry)
|
2018-06-19 20:12:52 -03:00
|
|
|
self.assertEqual(win.focused_widget, win)
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
unittest.main(verbosity=2)
|