summaryrefslogtreecommitdiffstats
path: root/Lib/idlelib/idle_test
diff options
context:
space:
mode:
authorTerry Jan Reedy <tjreedy@udel.edu>2017-09-11 00:30:46 (GMT)
committerGitHub <noreply@github.com>2017-09-11 00:30:46 (GMT)
commitd6c397bf772a8f17e00afc5e0a2cf37fdebcdf29 (patch)
tree69079c5b189dbc750d6bfa5ddcf489f15508c619 /Lib/idlelib/idle_test
parent28580316a57d1757978196c27286f989d21ec0f3 (diff)
downloadcpython-d6c397bf772a8f17e00afc5e0a2cf37fdebcdf29.zip
cpython-d6c397bf772a8f17e00afc5e0a2cf37fdebcdf29.tar.gz
cpython-d6c397bf772a8f17e00afc5e0a2cf37fdebcdf29.tar.bz2
[3.6] bpo-27099: IDLE - Convert built-in extensions to regular features (GH-2494) (#3487)
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. (cherry picked from commit 58fc71c)
Diffstat (limited to 'Lib/idlelib/idle_test')
-rw-r--r--Lib/idlelib/idle_test/test_config.py67
-rw-r--r--Lib/idlelib/idle_test/test_configdialog.py43
2 files changed, 58 insertions, 52 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
diff --git a/Lib/idlelib/idle_test/test_configdialog.py b/Lib/idlelib/idle_test/test_configdialog.py
index f116538..3d6a858 100644
--- a/Lib/idlelib/idle_test/test_configdialog.py
+++ b/Lib/idlelib/idle_test/test_configdialog.py
@@ -824,19 +824,20 @@ class KeysPageTest(unittest.TestCase):
d.custom_name.set('my custom keys')
d.bindingslist.delete(0, 'end')
d.bindingslist.insert(0, 'copy')
- d.bindingslist.insert(1, 'expand-word')
+ d.bindingslist.insert(1, 'z-in')
d.bindingslist.selection_set(0)
d.bindingslist.selection_anchor(0)
# Core binding - adds to keys.
d.keybinding.set('<Key-F11>')
self.assertEqual(keyspage,
{'my custom keys': {'copy': '<Key-F11>'}})
+
# Not a core binding - adds to extensions.
d.bindingslist.selection_set(1)
d.bindingslist.selection_anchor(1)
d.keybinding.set('<Key-F11>')
self.assertEqual(extpage,
- {'AutoExpand_cfgBindings': {'expand-word': '<Key-F11>'}})
+ {'ZzDummy_cfgBindings': {'z-in': '<Key-F11>'}})
def test_set_keys_type(self):
eq = self.assertEqual
@@ -1125,13 +1126,6 @@ class GenPageTest(unittest.TestCase):
self.assertEqual(mainpage,
{'General': {'editor-on-startup': '0'}})
- def test_autosave(self):
- d = self.page
- d.save_auto_on.invoke()
- self.assertEqual(mainpage, {'General': {'autosave': '1'}})
- d.save_ask_on.invoke()
- self.assertEqual(mainpage, {'General': {'autosave': '0'}})
-
def test_editor_size(self):
d = self.page
d.win_height_int.insert(0, '1')
@@ -1140,6 +1134,37 @@ class GenPageTest(unittest.TestCase):
d.win_width_int.insert(0, '1')
self.assertEqual(mainpage, {'EditorWindow': {'width': '180'}})
+ def test_autocomplete_wait(self):
+ self.page.auto_wait_int.insert(0, '1')
+ self.assertEqual(extpage, {'AutoComplete': {'popupwait': '12000'}})
+
+ def test_parenmatch(self):
+ d = self.page
+ eq = self.assertEqual
+ d.paren_style_type['menu'].invoke(0)
+ eq(extpage, {'ParenMatch': {'style': 'opener'}})
+ changes.clear()
+ d.paren_flash_time.insert(0, '2')
+ eq(extpage, {'ParenMatch': {'flash-delay': '2500'}})
+ changes.clear()
+ d.bell_on.invoke()
+ eq(extpage, {'ParenMatch': {'bell': 'False'}})
+
+ def test_autosave(self):
+ d = self.page
+ d.save_auto_on.invoke()
+ self.assertEqual(mainpage, {'General': {'autosave': '1'}})
+ d.save_ask_on.invoke()
+ self.assertEqual(mainpage, {'General': {'autosave': '0'}})
+
+ def test_paragraph(self):
+ self.page.format_width_int.insert(0, '1')
+ self.assertEqual(extpage, {'FormatParagraph': {'max-width': '172'}})
+
+ def test_context(self):
+ self.page.context_int.insert(0, '1')
+ self.assertEqual(extpage, {'CodeContext': {'numlines': '13'}})
+
def test_source_selected(self):
d = self.page
d.set = d.set_add_delete_state