Kaydet (Commit) 55698cc3 authored tarafından Cheryl Sabella's avatar Cheryl Sabella Kaydeden (comit) Terry Jan Reedy

bpo-35598: IDLE: Update config_key.py with PEP8 names (GH-11330)

A few other changes make the code easier to follow.
üst 0133f9fc
This diff is collapsed.
......@@ -141,12 +141,11 @@ _editor_window_spec = {
"Best to close editor first."
}
# Update once issue21519 is resolved.
GetKeysDialog_spec = {
'file': 'config_key',
'kwds': {'title': 'Test keybindings',
'action': 'find-again',
'currentKeySequences': [''] ,
'current_key_sequences': [['<Control-Key-g>', '<Key-F3>', '<Control-Key-G>']],
'_htest': True,
},
'msg': "Test for different key modifier sequences.\n"
......
"Test config_key, coverage 75%"
"Test config_key, coverage 82%"
from idlelib import config_key
from test.support import requires
......@@ -9,15 +9,15 @@ from idlelib.idle_test.mock_tk import Mbox_func
class ValidationTest(unittest.TestCase):
"Test validation methods: OK, KeysOK, bind_ok."
"Test validation methods: ok, keys_ok, bind_ok."
class Validator(config_key.GetKeysDialog):
def __init__(self, *args, **kwargs):
config_key.GetKeysDialog.__init__(self, *args, **kwargs)
class listKeysFinal:
class list_keys_final:
get = Func()
self.listKeysFinal = listKeysFinal
GetModifiers = Func()
self.list_keys_final = list_keys_final
get_modifiers = Func()
showerror = Mbox_func()
@classmethod
......@@ -31,7 +31,7 @@ class ValidationTest(unittest.TestCase):
@classmethod
def tearDownClass(cls):
cls.dialog.Cancel()
cls.dialog.cancel()
cls.root.update_idletasks()
cls.root.destroy()
del cls.dialog, cls.root
......@@ -42,49 +42,49 @@ class ValidationTest(unittest.TestCase):
# A test that sets a non-blank modifier list should reset it to [].
def test_ok_empty(self):
self.dialog.keyString.set(' ')
self.dialog.OK()
self.dialog.key_string.set(' ')
self.dialog.ok()
self.assertEqual(self.dialog.result, '')
self.assertEqual(self.dialog.showerror.message, 'No key specified.')
def test_ok_good(self):
self.dialog.keyString.set('<Key-F11>')
self.dialog.listKeysFinal.get.result = 'F11'
self.dialog.OK()
self.dialog.key_string.set('<Key-F11>')
self.dialog.list_keys_final.get.result = 'F11'
self.dialog.ok()
self.assertEqual(self.dialog.result, '<Key-F11>')
self.assertEqual(self.dialog.showerror.message, '')
def test_keys_no_ending(self):
self.assertFalse(self.dialog.KeysOK('<Control-Shift'))
self.assertFalse(self.dialog.keys_ok('<Control-Shift'))
self.assertIn('Missing the final', self.dialog.showerror.message)
def test_keys_no_modifier_bad(self):
self.dialog.listKeysFinal.get.result = 'A'
self.assertFalse(self.dialog.KeysOK('<Key-A>'))
self.dialog.list_keys_final.get.result = 'A'
self.assertFalse(self.dialog.keys_ok('<Key-A>'))
self.assertIn('No modifier', self.dialog.showerror.message)
def test_keys_no_modifier_ok(self):
self.dialog.listKeysFinal.get.result = 'F11'
self.assertTrue(self.dialog.KeysOK('<Key-F11>'))
self.dialog.list_keys_final.get.result = 'F11'
self.assertTrue(self.dialog.keys_ok('<Key-F11>'))
self.assertEqual(self.dialog.showerror.message, '')
def test_keys_shift_bad(self):
self.dialog.listKeysFinal.get.result = 'a'
self.dialog.GetModifiers.result = ['Shift']
self.assertFalse(self.dialog.KeysOK('<a>'))
self.dialog.list_keys_final.get.result = 'a'
self.dialog.get_modifiers.result = ['Shift']
self.assertFalse(self.dialog.keys_ok('<a>'))
self.assertIn('shift modifier', self.dialog.showerror.message)
self.dialog.GetModifiers.result = []
self.dialog.get_modifiers.result = []
def test_keys_dup(self):
for mods, final, seq in (([], 'F12', '<Key-F12>'),
(['Control'], 'x', '<Control-Key-x>'),
(['Control'], 'X', '<Control-Key-X>')):
with self.subTest(m=mods, f=final, s=seq):
self.dialog.listKeysFinal.get.result = final
self.dialog.GetModifiers.result = mods
self.assertFalse(self.dialog.KeysOK(seq))
self.dialog.list_keys_final.get.result = final
self.dialog.get_modifiers.result = mods
self.assertFalse(self.dialog.keys_ok(seq))
self.assertIn('already in use', self.dialog.showerror.message)
self.dialog.GetModifiers.result = []
self.dialog.get_modifiers.result = []
def test_bind_ok(self):
self.assertTrue(self.dialog.bind_ok('<Control-Shift-Key-a>'))
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment