bpo-31480: IDLE - fix tests to pass with zzdummy extension disabled. (#3590)

Enabled by default was a temporary expedient.  The fix is to add a user override to enable.
This commit is contained in:
Terry Jan Reedy 2017-09-14 18:51:51 -04:00 committed by GitHub
parent 6a396c9807
commit d384a81f55
4 changed files with 40 additions and 44 deletions

View File

@ -55,7 +55,7 @@ bell= True
# A fake extension for testing and example purposes. When enabled and # A fake extension for testing and example purposes. When enabled and
# invoked, inserts or deletes z-text at beginning of every line. # invoked, inserts or deletes z-text at beginning of every line.
[ZzDummy] [ZzDummy]
enable= True enable= False
enable_shell = False enable_shell = False
enable_editor = True enable_editor = True
z-text= Z z-text= Z

View File

@ -26,6 +26,7 @@ testcfg = {}
usermain = testcfg['main'] = config.IdleUserConfParser('') usermain = testcfg['main'] = config.IdleUserConfParser('')
userhigh = testcfg['highlight'] = config.IdleUserConfParser('') userhigh = testcfg['highlight'] = config.IdleUserConfParser('')
userkeys = testcfg['keys'] = config.IdleUserConfParser('') userkeys = testcfg['keys'] = config.IdleUserConfParser('')
userextn = testcfg['extensions'] = config.IdleUserConfParser('')
def setUpModule(): def setUpModule():
idleConf.userCfg = testcfg idleConf.userCfg = testcfg
@ -430,29 +431,22 @@ class IdleConfTest(unittest.TestCase):
sys.platform = current_platform sys.platform = current_platform
def test_get_extensions(self): def test_get_extensions(self):
conf = self.mock_config() userextn.read_string('''
[ZzDummy]
# Add disable extensions enable = True
conf.SetOption('extensions', 'DISABLE', 'enable', 'False') [DISABLE]
enable = False
''')
eq = self.assertEqual eq = self.assertEqual
eq(conf.GetExtensions(), iGE = idleConf.GetExtensions
['ZzDummy']) eq(iGE(shell_only=True), [])
eq(conf.GetExtensions(active_only=False), eq(iGE(), ['ZzDummy'])
['ZzDummy', 'DISABLE']) eq(iGE(editor_only=True), ['ZzDummy'])
eq(conf.GetExtensions(editor_only=True), eq(iGE(active_only=False), ['ZzDummy', 'DISABLE'])
['ZzDummy']) eq(iGE(active_only=False, editor_only=True), ['ZzDummy', 'DISABLE'])
eq(conf.GetExtensions(shell_only=True), userextn.remove_section('ZzDummy')
[]) userextn.remove_section('DISABLE')
eq(conf.GetExtensions(active_only=False, editor_only=True),
['ZzDummy', 'DISABLE'])
# Add user extensions
conf.SetOption('extensions', 'Foobar', 'enable', 'True')
eq(conf.GetExtensions(),
['ZzDummy', 'Foobar']) # User extensions didn't sort
eq(conf.GetExtensions(active_only=False),
['ZzDummy', 'DISABLE', 'Foobar'])
def test_remove_key_bind_names(self): def test_remove_key_bind_names(self):
conf = self.mock_config() conf = self.mock_config()
@ -462,39 +456,39 @@ class IdleConfTest(unittest.TestCase):
['AutoComplete', 'CodeContext', 'FormatParagraph', 'ParenMatch','ZzDummy']) ['AutoComplete', 'CodeContext', 'FormatParagraph', 'ParenMatch','ZzDummy'])
def test_get_extn_name_for_event(self): def test_get_extn_name_for_event(self):
conf = self.mock_config() userextn.read_string('''
[ZzDummy]
enable = True
''')
eq = self.assertEqual eq = self.assertEqual
eq(conf.GetExtnNameForEvent('z-in'), 'ZzDummy') eq(idleConf.GetExtnNameForEvent('z-in'), 'ZzDummy')
eq(conf.GetExtnNameForEvent('z-out'), None) eq(idleConf.GetExtnNameForEvent('z-out'), None)
userextn.remove_section('ZzDummy')
def test_get_extension_keys(self): def test_get_extension_keys(self):
conf = self.mock_config() userextn.read_string('''
[ZzDummy]
eq = self.assertEqual enable = True
eq(conf.GetExtensionKeys('ZzDummy'), ''')
self.assertEqual(idleConf.GetExtensionKeys('ZzDummy'),
{'<<z-in>>': ['<Control-Shift-KeyRelease-Insert>']}) {'<<z-in>>': ['<Control-Shift-KeyRelease-Insert>']})
userextn.remove_section('ZzDummy')
# need option key test # need option key test
## key = ['<Option-Key-2>'] if sys.platform == 'darwin' else ['<Alt-Key-2>'] ## key = ['<Option-Key-2>'] if sys.platform == 'darwin' else ['<Alt-Key-2>']
## eq(conf.GetExtensionKeys('ZoomHeight'), {'<<zoom-height>>': key}) ## eq(conf.GetExtensionKeys('ZoomHeight'), {'<<zoom-height>>': key})
def test_get_extension_bindings(self): def test_get_extension_bindings(self):
conf = self.mock_config() userextn.read_string('''
[ZzDummy]
self.assertEqual(conf.GetExtensionBindings('NotExists'), {}) enable = True
''')
#key = ['<Option-Key-2>'] if sys.platform == 'darwin' else ['<Alt-Key-2>'] eq = self.assertEqual
iGEB = idleConf.GetExtensionBindings
eq(iGEB('NotExists'), {})
expect = {'<<z-in>>': ['<Control-Shift-KeyRelease-Insert>'], expect = {'<<z-in>>': ['<Control-Shift-KeyRelease-Insert>'],
'<<z-out>>': ['<Control-Shift-KeyRelease-Delete>']} '<<z-out>>': ['<Control-Shift-KeyRelease-Delete>']}
self.assertEqual( eq(iGEB('ZzDummy'), expect)
conf.GetExtensionBindings('ZzDummy'), expect) userextn.remove_section('ZzDummy')
# Add non-configuarable bindings
conf.defaultCfg['extensions'].add_section('Foobar')
conf.defaultCfg['extensions'].add_section('Foobar_bindings')
conf.defaultCfg['extensions'].set('Foobar', 'enable', 'True')
conf.defaultCfg['extensions'].set('Foobar_bindings', 'foobar', '<Key-F>')
self.assertEqual(conf.GetExtensionBindings('Foobar'), {'<<foobar>>': ['<Key-F>']})
def test_get_keybinding(self): def test_get_keybinding(self):
conf = self.mock_config() conf = self.mock_config()

View File

@ -820,6 +820,7 @@ class KeysPageTest(unittest.TestCase):
self.assertEqual(d.load_keys_list.called, 1) self.assertEqual(d.load_keys_list.called, 1)
def test_keybinding(self): def test_keybinding(self):
idleConf.SetOption('extensions', 'ZzDummy', 'enable', 'True')
d = self.page d = self.page
d.custom_name.set('my custom keys') d.custom_name.set('my custom keys')
d.bindingslist.delete(0, 'end') d.bindingslist.delete(0, 'end')

View File

@ -0,0 +1 @@
IDLE - make tests pass with zzdummy extension disabled by default.