Coverage for idle_test/test_iomenu.py: 54%
54 statements
« prev ^ index » next coverage.py v7.2.5, created at 2023-05-11 13:22 -0700
« prev ^ index » next coverage.py v7.2.5, created at 2023-05-11 13:22 -0700
1"Test , coverage 17%."
3from idlelib import iomenu
4import unittest
5from test.support import requires
6from tkinter import Tk
7from idlelib.editor import EditorWindow
8from idlelib import util
9from idlelib.idle_test.mock_idle import Func
12class IOBindingTest(unittest.TestCase):
14 @classmethod
15 def setUpClass(cls):
16 requires('gui')
17 cls.root = Tk()
18 cls.root.withdraw()
19 cls.editwin = EditorWindow(root=cls.root)
20 cls.io = iomenu.IOBinding(cls.editwin)
22 @classmethod
23 def tearDownClass(cls):
24 cls.io.close()
25 cls.editwin._close()
26 del cls.editwin
27 cls.root.update_idletasks()
28 for id in cls.root.tk.call('after', 'info'):
29 cls.root.after_cancel(id) # Need for EditorWindow.
30 cls.root.destroy()
31 del cls.root
33 def test_init(self):
34 self.assertIs(self.io.editwin, self.editwin)
36 def test_fixnewlines_end(self):
37 eq = self.assertEqual
38 io = self.io
39 fix = io.fixnewlines
40 text = io.editwin.text
42 # Make the editor temporarily look like Shell.
43 self.editwin.interp = None
44 shelltext = '>>> if 1'
45 self.editwin.get_prompt_text = Func(result=shelltext)
46 eq(fix(), shelltext) # Get... call and '\n' not added.
47 del self.editwin.interp, self.editwin.get_prompt_text
49 text.insert(1.0, 'a')
50 eq(fix(), 'a'+io.eol_convention)
51 eq(text.get('1.0', 'end-1c'), 'a\n')
52 eq(fix(), 'a'+io.eol_convention)
55def _extension_in_filetypes(extension):
56 return any( 56 ↛ exitline 56 didn't finish the generator expression on line 561cbd
57 f'*{extension}' in filetype_tuple[1]
58 for filetype_tuple in iomenu.IOBinding.filetypes
59 )
62class FiletypesTest(unittest.TestCase):
63 def test_python_source_files(self):
64 for extension in util.py_extensions: 1b
65 with self.subTest(extension=extension): 1b
66 self.assertTrue( 1b
67 _extension_in_filetypes(extension)
68 )
70 def test_text_files(self):
71 self.assertTrue(_extension_in_filetypes('.txt')) 1d
73 def test_all_files(self):
74 self.assertTrue(_extension_in_filetypes('')) 1c
77if __name__ == '__main__': 77 ↛ 78line 77 didn't jump to line 78, because the condition on line 77 was never true
78 unittest.main(verbosity=2)