diff options
author | Cheryl Sabella <cheryl.sabella@gmail.com> | 2018-12-31 20:06:35 (GMT) |
---|---|---|
committer | Terry Jan Reedy <tjreedy@udel.edu> | 2018-12-31 20:06:35 (GMT) |
commit | b4ea8bb080f63ef27682f3f9bbaa4d12a83030b1 (patch) | |
tree | c7ce85464ae15ffa138fd83397da56536943582d /Lib/idlelib/idle_test/test_config_key.py | |
parent | ede0b6fae20290bf22b6ee1b9a1e1179d750f360 (diff) | |
download | cpython-b4ea8bb080f63ef27682f3f9bbaa4d12a83030b1.zip cpython-b4ea8bb080f63ef27682f3f9bbaa4d12a83030b1.tar.gz cpython-b4ea8bb080f63ef27682f3f9bbaa4d12a83030b1.tar.bz2 |
bpo-35598: IDLE - Globalize some config_key objects (GH-11392)
Move translate_key() and constant tuples to module level.
Inline the remnant one-line function.
Diffstat (limited to 'Lib/idlelib/idle_test/test_config_key.py')
-rw-r--r-- | Lib/idlelib/idle_test/test_config_key.py | 41 |
1 files changed, 22 insertions, 19 deletions
diff --git a/Lib/idlelib/idle_test/test_config_key.py b/Lib/idlelib/idle_test/test_config_key.py index 8261f8d..b7fe7fd 100644 --- a/Lib/idlelib/idle_test/test_config_key.py +++ b/Lib/idlelib/idle_test/test_config_key.py @@ -206,25 +206,6 @@ class KeySelectionTest(unittest.TestCase): dialog.modifier_checkbuttons['foo'].invoke() eq(gm(), ['BAZ']) - def test_translate_key(self): - dialog = self.dialog - tr = dialog.translate_key - eq = self.assertEqual - - # Letters return unchanged with no 'Shift'. - eq(tr('q', []), 'Key-q') - eq(tr('q', ['Control', 'Alt']), 'Key-q') - - # 'Shift' uppercases single lowercase letters. - eq(tr('q', ['Shift']), 'Key-Q') - eq(tr('q', ['Control', 'Shift']), 'Key-Q') - eq(tr('q', ['Control', 'Alt', 'Shift']), 'Key-Q') - - # Convert key name to keysym. - eq(tr('Page Up', []), 'Key-Prior') - # 'Shift' doesn't change case. - eq(tr('Page Down', ['Shift']), 'Key-Next') - @mock.patch.object(gkd, 'get_modifiers') def test_build_key_string(self, mock_modifiers): dialog = self.dialog @@ -284,5 +265,27 @@ class CancelTest(unittest.TestCase): self.assertEqual(self.dialog.result, '') +class HelperTest(unittest.TestCase): + "Test module level helper functions." + + def test_translate_key(self): + tr = config_key.translate_key + eq = self.assertEqual + + # Letters return unchanged with no 'Shift'. + eq(tr('q', []), 'Key-q') + eq(tr('q', ['Control', 'Alt']), 'Key-q') + + # 'Shift' uppercases single lowercase letters. + eq(tr('q', ['Shift']), 'Key-Q') + eq(tr('q', ['Control', 'Shift']), 'Key-Q') + eq(tr('q', ['Control', 'Alt', 'Shift']), 'Key-Q') + + # Convert key name to keysym. + eq(tr('Page Up', []), 'Key-Prior') + # 'Shift' doesn't change case when it's not a single char. + eq(tr('*', ['Shift']), 'Key-asterisk') + + if __name__ == '__main__': unittest.main(verbosity=2) |