cpython: e6e6c71776b0 (original) (raw)

Mercurial > cpython

changeset 102300:e6e6c71776b0

Issue #27173: Add 'IDLE Modern Unix' to the built-in key sets. Make the default key set depend on the platform. Add tests for changes to the config module. [#27173]

Terry Jan Reedy tjreedy@udel.edu
date Sun, 10 Jul 2016 13:46:34 -0400
parents 31cdf23da19d
children a9c11fecd83b
files Lib/idlelib/config-keys.def Lib/idlelib/config-main.def Lib/idlelib/config.py Lib/idlelib/configdialog.py Lib/idlelib/idle_test/test_config.py
diffstat 5 files changed, 270 insertions(+), 57 deletions(-)[+] [-] Lib/idlelib/config-keys.def 51 Lib/idlelib/config-main.def 4 Lib/idlelib/config.py 130 Lib/idlelib/configdialog.py 44 Lib/idlelib/idle_test/test_config.py 98

line wrap: on

line diff

--- a/Lib/idlelib/config-keys.def +++ b/Lib/idlelib/config-keys.def @@ -109,6 +109,57 @@ change-indentwidth= del-word-left= del-word-right= +[IDLE Modern Unix] +copy = +cut = +paste = +beginning-of-line = +center-insert = +close-all-windows = +close-window = +do-nothing = +end-of-file = +history-next = +history-previous = +interrupt-execution = +view-restart = +restart-shell = +open-class-browser = +open-module = +open-new-window = +open-window-from-file = +plain-newline-and-indent = +print-window = +python-context-help = +python-docs = +redo = +remove-selection = +save-copy-of-window-as-file = +save-window-as-file = +save-window = +select-all = +toggle-auto-coloring = +undo = +find = +find-again = +find-in-files = +find-selection = +replace = +goto-line = +smart-backspace = +newline-and-indent = +smart-indent = +indent-region = +dedent-region = +comment-region = +uncomment-region = +tabify-region = +untabify-region = +toggle-tabs = +change-indentwidth = +del-word-left = +del-word-right = + [IDLE Classic Mac] copy= cut=

--- a/Lib/idlelib/config-main.def +++ b/Lib/idlelib/config-main.def @@ -70,7 +70,9 @@ name2= [Keys] default= 1 -name= IDLE Classic Windows +name= +name2= +# name2 set in user config-main.cfg for keys added after 2016 July 1 [History] cyclic=1

--- a/Lib/idlelib/config.py +++ b/Lib/idlelib/config.py @@ -234,10 +234,7 @@ class IdleConf: ' from section %r: %r' % (type, option, section, self.userCfg[configType].Get(section, option, raw=raw)))

@@ -251,10 +248,7 @@ class IdleConf: ' from section %r.\n' ' returning default value: %r' % (option, section, default))

def SetOption(self, configType, section, option, value): @@ -362,47 +356,68 @@ class IdleConf: '\n from theme %r.\n' ' returning default color: %r' % (element, themeName, theme[element]))

def CurrentTheme(self):

+

+

+ [Theme] default= 1 name= IDLE Classic name2=

+

+

-

If active_only True, only return active (enabled) extensions @@ -422,7 +437,7 @@ class IdleConf: if self.GetOption('extensions', extn, 'enable', default=True, type='bool'): #the extension is enabled

@@ -527,7 +542,8 @@ class IdleConf: eventStr - virtual event, including brackets, as in '<>'. """ eventName = eventStr[2:-2] #trim off the angle brackets

def GetCurrentKeySet(self): @@ -638,20 +654,28 @@ class IdleConf: '<>': [''] } if keySetName:

def GetExtraHelpSourceList(self, configSet): @@ -735,6 +759,18 @@ class IdleConf: idleConf = IdleConf() + +_warned = set() +def _warn(msg, *key):

+ +

TODO Revise test output, write expanded unittest

# if name == 'main':

--- a/Lib/idlelib/configdialog.py +++ b/Lib/idlelib/configdialog.py @@ -341,6 +341,7 @@ class ConfigDialog(Toplevel): buttonSaveCustomKeys = Button( frames[1], text='Save as New Custom Key Set', command=self.SaveAsNewKeySet)

##widget packing #body @@ -361,6 +362,7 @@ class ConfigDialog(Toplevel): self.radioKeysCustom.grid(row=1, column=0, sticky=W+NS) self.optMenuKeysBuiltin.grid(row=0, column=1, sticky=NSEW) self.optMenuKeysCustom.grid(row=1, column=1, sticky=NSEW)

@@ -514,10 +516,11 @@ class ConfigDialog(Toplevel): self.OnNewColourSet() def VarChanged_builtinTheme(self, *params):

@@ -557,8 +560,23 @@ class ConfigDialog(Toplevel): self.AddChangedItem('extensions', extKeybindSection, event, value) def VarChanged_builtinKeys(self, *params):

def VarChanged_customKeys(self, *params): @@ -767,8 +785,10 @@ class ConfigDialog(Toplevel): else: self.optMenuKeysCustom.SetMenu(itemList, itemList[0]) #revert to default key set

@@ -1067,7 +1087,7 @@ class ConfigDialog(Toplevel): self.optMenuKeysCustom.SetMenu(itemList, currentOption) itemList = idleConf.GetSectionList('default', 'keys') itemList.sort()

@@ -1369,12 +1389,18 @@ machine. Some do not take affect until I [Cancel] only cancels changes made since the last save. ''' help_pages = {

Highlighting: The IDLE Dark color theme is new in October 2015. It can only be used with older IDLE releases if it is saved as a custom theme, with a different name. -''' +''',

+Keys: +The IDLE Modern Unix key set is new in June 2016. It can only +be used with older IDLE releases if it is saved as a custom +key set, with a different name. +''', }

new file mode 100644 --- /dev/null +++ b/Lib/idlelib/idle_test/test_config.py @@ -0,0 +1,98 @@ +'''Test idlelib.config. + +Much is tested by opening config dialog live or in test_configdialog. +Coverage: 27% +''' +from sys import modules +from test.support import captured_stderr +from tkinter import Tk +import unittest +from idlelib import config + +# Tests should not depend on fortuitous user configurations. +# They must not affect actual user .cfg files. +# Replace user parsers with empty parsers that cannot be saved. + +idleConf = config.idleConf +usercfg = idleConf.userCfg +testcfg = {} +usermain = testcfg['main'] = config.IdleUserConfParser('') # filename +userhigh = testcfg['highlight'] = config.IdleUserConfParser('') +userkeys = testcfg['keys'] = config.IdleUserConfParser('') + +def setUpModule():

+ +def tearDownModule():

+ + +class CurrentColorKeysTest(unittest.TestCase):

+

+

+

+

+ + +class WarningTest(unittest.TestCase): +

+ + +if name == 'main':