1"Test , coverage 17%." 2 3from idlelib import iomenu 4import unittest 5from test.support import requires 6from tkinter import Tk 7from idlelib.editor import EditorWindow 8 9 10class IOBindingTest(unittest.TestCase): 11 12 @classmethod 13 def setUpClass(cls): 14 requires('gui') 15 cls.root = Tk() 16 cls.root.withdraw() 17 cls.editwin = EditorWindow(root=cls.root) 18 cls.io = iomenu.IOBinding(cls.editwin) 19 20 @classmethod 21 def tearDownClass(cls): 22 cls.io.close() 23 cls.editwin._close() 24 del cls.editwin 25 cls.root.update_idletasks() 26 for id in cls.root.tk.call('after', 'info'): 27 cls.root.after_cancel(id) # Need for EditorWindow. 28 cls.root.destroy() 29 del cls.root 30 31 def test_init(self): 32 self.assertIs(self.io.editwin, self.editwin) 33 34 def test_fixnewlines_end(self): 35 eq = self.assertEqual 36 io = self.io 37 fix = io.fixnewlines 38 text = io.editwin.text 39 self.editwin.interp = None 40 eq(fix(), '') 41 del self.editwin.interp 42 text.insert(1.0, 'a') 43 eq(fix(), 'a'+io.eol_convention) 44 eq(text.get('1.0', 'end-1c'), 'a\n') 45 eq(fix(), 'a'+io.eol_convention) 46 47 48if __name__ == '__main__': 49 unittest.main(verbosity=2) 50