summaryrefslogtreecommitdiffstats
path: root/Lib/idlelib/idle_test/test_config.py
diff options
context:
space:
mode:
authorwohlganger <charles.wohlganger@gmail.com>2017-09-10 21:19:47 (GMT)
committerTerry Jan Reedy <tjreedy@udel.edu>2017-09-10 21:19:47 (GMT)
commit58fc71c447049d0efe4e11db1b55edc307f1bede (patch)
tree237891f31c741848809fa8dab7b6652849f37fa0 /Lib/idlelib/idle_test/test_config.py
parentd39dbf4cf18488beb190ab358b7ab38792cd5043 (diff)
downloadcpython-58fc71c447049d0efe4e11db1b55edc307f1bede.zip
cpython-58fc71c447049d0efe4e11db1b55edc307f1bede.tar.gz
cpython-58fc71c447049d0efe4e11db1b55edc307f1bede.tar.bz2
bpo-27099: IDLE - Convert built-in extensions to regular features (#2494)
About 10 IDLE features were implemented as supposedly optional extensions. Their different behavior could be confusing or worse for users and not good for maintenance. Hence the conversion. The main difference for users is that user configurable key bindings for builtin features are now handled uniformly. Now, editing a binding in a keyset only affects its value in the keyset. All bindings are defined together in the system-specific default keysets in config- extensions.def. All custom keysets are saved as a whole in config- extension.cfg. All take effect as soon as one clicks Apply or Ok. The affected events are '<<force-open-completions>>', '<<expand-word>>', '<<force-open-calltip>>', '<<flash-paren>>', '<<format-paragraph>>', '<<run-module>>', '<<check-module>>', and '<<zoom-height>>'. Any (global) customizations made before 3.6.3 will not affect their keyset- specific customization after 3.6.3. and vice versa. Inital patch by Charles Wohlganger, revised by Terry Jan Reedy.
Diffstat (limited to 'Lib/idlelib/idle_test/test_config.py')
-rw-r--r--Lib/idlelib/idle_test/test_config.py67
1 files changed, 24 insertions, 43 deletions
diff --git a/Lib/idlelib/idle_test/test_config.py b/Lib/idlelib/idle_test/test_config.py
index bbf0650..84b45a6 100644
--- a/Lib/idlelib/idle_test/test_config.py
+++ b/Lib/idlelib/idle_test/test_config.py
@@ -437,78 +437,57 @@ class IdleConfTest(unittest.TestCase):
eq = self.assertEqual
eq(conf.GetExtensions(),
- ['AutoComplete', 'AutoExpand', 'CallTips', 'CodeContext',
- 'FormatParagraph', 'ParenMatch', 'RstripExtension', 'ScriptBinding',
- 'ZoomHeight'])
+ ['ZzDummy'])
eq(conf.GetExtensions(active_only=False),
- ['AutoComplete', 'AutoExpand', 'CallTips', 'CodeContext',
- 'FormatParagraph', 'ParenMatch', 'RstripExtension', 'ScriptBinding',
- 'ZoomHeight', 'DISABLE'])
+ ['ZzDummy', 'DISABLE'])
eq(conf.GetExtensions(editor_only=True),
- ['AutoComplete', 'AutoExpand', 'CallTips', 'CodeContext',
- 'FormatParagraph', 'ParenMatch', 'RstripExtension', 'ScriptBinding',
- 'ZoomHeight'])
+ ['ZzDummy'])
eq(conf.GetExtensions(shell_only=True),
- ['AutoComplete', 'AutoExpand', 'CallTips', 'FormatParagraph',
- 'ParenMatch', 'ZoomHeight'])
+ [])
eq(conf.GetExtensions(active_only=False, editor_only=True),
- ['AutoComplete', 'AutoExpand', 'CallTips', 'CodeContext',
- 'FormatParagraph', 'ParenMatch', 'RstripExtension',
- 'ScriptBinding', 'ZoomHeight', 'DISABLE'])
- eq(conf.GetExtensions(active_only=False, shell_only=True),
- ['AutoComplete', 'AutoExpand', 'CallTips', 'CodeContext',
- 'FormatParagraph', 'ParenMatch', 'RstripExtension', 'ScriptBinding',
- 'ZoomHeight', 'DISABLE'])
+ ['ZzDummy', 'DISABLE'])
# Add user extensions
conf.SetOption('extensions', 'Foobar', 'enable', 'True')
eq(conf.GetExtensions(),
- ['AutoComplete', 'AutoExpand', 'CallTips', 'CodeContext',
- 'FormatParagraph', 'ParenMatch', 'RstripExtension',
- 'ScriptBinding', 'ZoomHeight', 'Foobar']) # User extensions didn't sort
+ ['ZzDummy', 'Foobar']) # User extensions didn't sort
eq(conf.GetExtensions(active_only=False),
- ['AutoComplete', 'AutoExpand', 'CallTips', 'CodeContext',
- 'FormatParagraph', 'ParenMatch', 'RstripExtension',
- 'ScriptBinding', 'ZoomHeight', 'DISABLE', 'Foobar'])
+ ['ZzDummy', 'DISABLE', 'Foobar'])
def test_remove_key_bind_names(self):
conf = self.mock_config()
self.assertCountEqual(
conf.RemoveKeyBindNames(conf.GetSectionList('default', 'extensions')),
- ['AutoComplete', 'AutoExpand', 'CallTips', 'CodeContext',
- 'FormatParagraph', 'ParenMatch', 'RstripExtension', 'ScriptBinding',
- 'ZoomHeight'])
+ ['AutoComplete', 'CodeContext', 'FormatParagraph', 'ParenMatch','ZzDummy'])
def test_get_extn_name_for_event(self):
conf = self.mock_config()
eq = self.assertEqual
- eq(conf.GetExtnNameForEvent('force-open-completions'), 'AutoComplete')
- eq(conf.GetExtnNameForEvent('expand-word'), 'AutoExpand')
- eq(conf.GetExtnNameForEvent('force-open-calltip'), 'CallTips')
- eq(conf.GetExtnNameForEvent('zoom-height'), 'ZoomHeight')
+ eq(conf.GetExtnNameForEvent('z-in'), 'ZzDummy')
+ eq(conf.GetExtnNameForEvent('z-out'), None)
def test_get_extension_keys(self):
conf = self.mock_config()
eq = self.assertEqual
- eq(conf.GetExtensionKeys('AutoComplete'),
- {'<<force-open-completions>>': ['<Control-Key-space>']})
- eq(conf.GetExtensionKeys('ParenMatch'),
- {'<<flash-paren>>': ['<Control-Key-0>']})
-
- key = ['<Option-Key-2>'] if sys.platform == 'darwin' else ['<Alt-Key-2>']
- eq(conf.GetExtensionKeys('ZoomHeight'), {'<<zoom-height>>': key})
+ eq(conf.GetExtensionKeys('ZzDummy'),
+ {'<<z-in>>': ['<Control-Shift-KeyRelease-Insert>']})
+# need option key test
+## key = ['<Option-Key-2>'] if sys.platform == 'darwin' else ['<Alt-Key-2>']
+## eq(conf.GetExtensionKeys('ZoomHeight'), {'<<zoom-height>>': key})
def test_get_extension_bindings(self):
conf = self.mock_config()
self.assertEqual(conf.GetExtensionBindings('NotExists'), {})
- key = ['<Option-Key-2>'] if sys.platform == 'darwin' else ['<Alt-Key-2>']
+ #key = ['<Option-Key-2>'] if sys.platform == 'darwin' else ['<Alt-Key-2>']
+ expect = {'<<z-in>>': ['<Control-Shift-KeyRelease-Insert>'],
+ '<<z-out>>': ['<Control-Shift-KeyRelease-Delete>']}
self.assertEqual(
- conf.GetExtensionBindings('ZoomHeight'), {'<<zoom-height>>': key})
+ conf.GetExtensionBindings('ZzDummy'), expect)
# Add non-configuarable bindings
conf.defaultCfg['extensions'].add_section('Foobar')
@@ -542,9 +521,11 @@ class IdleConfTest(unittest.TestCase):
sys.platform = 'some-linux'
self.assertEqual(conf.GetCurrentKeySet(), conf.GetKeySet(conf.CurrentKeys()))
- # This should not be the same, sicne replace <Alt- to <Option-
- sys.platform = 'darwin'
- self.assertNotEqual(conf.GetCurrentKeySet(), conf.GetKeySet(conf.CurrentKeys()))
+ # This should not be the same, since replace <Alt- to <Option-.
+ # Above depended on config-extensions.def having Alt keys,
+ # which is no longer true.
+ # sys.platform = 'darwin'
+ # self.assertNotEqual(conf.GetCurrentKeySet(), conf.GetKeySet(conf.CurrentKeys()))
# Restore platform
sys.platform = current_platform