Coverage for idle_test/test_mainmenu.py: 85%
20 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 mainmenu, coverage 100%."
2# Reported as 88%; mocking turtledemo absence would have no point.
4from idlelib import mainmenu
5import re
6import unittest
9class MainMenuTest(unittest.TestCase):
11 def test_menudefs(self):
12 actual = [item[0] for item in mainmenu.menudefs] 1c
13 expect = ['file', 'edit', 'format', 'run', 'shell', 1c
14 'debug', 'options', 'window', 'help']
15 self.assertEqual(actual, expect) 1c
17 def test_default_keydefs(self):
18 self.assertGreaterEqual(len(mainmenu.default_keydefs), 50) 1d
20 def test_tcl_indexes(self):
21 # Test tcl patterns used to find menuitem to alter.
22 # On failure, change pattern here and in function(s).
23 # Patterns here have '.*' for re instead of '*' for tcl.
24 for menu, pattern in ( 1b
25 ('debug', '.*tack.*iewer'), # PyShell.debug_menu_postcommand
26 ('options', '.*ode.*ontext'), # EW.__init__, CodeContext.toggle...
27 ('options', '.*ine.*umbers'), # EW.__init__, EW.toggle...event.
28 ):
29 with self.subTest(menu=menu, pattern=pattern): 1b
30 for menutup in mainmenu.menudefs: 30 ↛ 34line 30 didn't jump to line 34, because the loop on line 30 didn't complete1b
31 if menutup[0] == menu: 1b
32 break 1b
33 else:
34 self.assertTrue(0, f"{menu} not in menudefs")
35 self.assertTrue(any(re.search(pattern, menuitem[0]) 35 ↛ exitline 35 didn't finish the generator expression on line 351b
36 for menuitem in menutup[1]
37 if menuitem is not None), # Separator.
38 f"{pattern} not in {menu}")
41if __name__ == '__main__': 41 ↛ 42line 41 didn't jump to line 42, because the condition on line 41 was never true
42 unittest.main(verbosity=2)