From 1113f2ae1c89e5faf90869f57d36f2ab552faeb3 Mon Sep 17 00:00:00 2001 From: Terry Jan Reedy Date: Fri, 14 Jul 2017 21:41:32 -0400 Subject: [PATCH 1/4] Document idlelib test coverage. --- Lib/idlelib/idle_test/README.txt | 52 ++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) diff --git a/Lib/idlelib/idle_test/README.txt b/Lib/idlelib/idle_test/README.txt index dc7a28697c1988..554b48c4f12bbc 100644 --- a/Lib/idlelib/idle_test/README.txt +++ b/Lib/idlelib/idle_test/README.txt @@ -159,3 +159,55 @@ complete, though some tests need improvement. To run all htests, run the htest file from an editor or from the command line with: python -m idlelib.idle_test.htest + + +5. Test Coverage + +(The following works for Windows. Adjust for other systems.) + +Install coverage package into py3.6/Lib/site-packages with +> py -3.6 -m pip install coverage +Problem with running coverage with repository python is that coverage +uses absolute imports for its submodules, hence needs to be in a +directory in sys.path. One solution: copy the package to the directory +containing the cpython repository. Call it 'dev' + +Add dev/.coveragerc containing something like the following: +--- +# .coveragerc sets coverage options. +[run] +branch = True + +[report] +# Regexes for lines to exclude from consideration +exclude_lines = + # Don't complain if non-runnable code isn't run: + if 0: + if __name__ == .__main__.: + + .*# htest # + if not _utest: + if _htest: +--- +The 'branch = True' and last three exclude lines are added. If file +exists already (coverage will create it), add these four lines. + +Optionally, add a script like the following: +--- +@echo off +rem Usage: cover filename [test_ suffix] # proper case required by coverage +rem filename without .py, 2nd parameter if test is not test_filename +setlocal +set py=f:\dev\3x\pcbuild\win32\python_d.exe +set src=idlelib.%1 +if "%2" EQU "" set tst=f:/dev/3x/Lib/idlelib/idle_test/test_%1.py +if "%2" NEQ "" set tst=f:/dev/ex/Lib/idlelib/idle_test/test_%2.py + +%py% -m coverage run --pylib --source=%src% %tst% +%py% -m coverage report --show-missing +%py% -m coverage html +start htmlcov\3x_Lib_idlelib_%1_py.html +rem Above opens new report; htmlcov\index.html displays report index +--- +The second parameter was needed for tests of module x not named test_x. +(There were several before modules were renamed, now only one.) \ No newline at end of file From 0377e4365d3038930c109b6848609e61b81bc1e0 Mon Sep 17 00:00:00 2001 From: Terry Jan Reedy Date: Fri, 14 Jul 2017 22:06:32 -0400 Subject: [PATCH 2/4] undo? --- Lib/idlelib/idle_test/README.txt | 52 -------------------------------- 1 file changed, 52 deletions(-) diff --git a/Lib/idlelib/idle_test/README.txt b/Lib/idlelib/idle_test/README.txt index 554b48c4f12bbc..dc7a28697c1988 100644 --- a/Lib/idlelib/idle_test/README.txt +++ b/Lib/idlelib/idle_test/README.txt @@ -159,55 +159,3 @@ complete, though some tests need improvement. To run all htests, run the htest file from an editor or from the command line with: python -m idlelib.idle_test.htest - - -5. Test Coverage - -(The following works for Windows. Adjust for other systems.) - -Install coverage package into py3.6/Lib/site-packages with -> py -3.6 -m pip install coverage -Problem with running coverage with repository python is that coverage -uses absolute imports for its submodules, hence needs to be in a -directory in sys.path. One solution: copy the package to the directory -containing the cpython repository. Call it 'dev' - -Add dev/.coveragerc containing something like the following: ---- -# .coveragerc sets coverage options. -[run] -branch = True - -[report] -# Regexes for lines to exclude from consideration -exclude_lines = - # Don't complain if non-runnable code isn't run: - if 0: - if __name__ == .__main__.: - - .*# htest # - if not _utest: - if _htest: ---- -The 'branch = True' and last three exclude lines are added. If file -exists already (coverage will create it), add these four lines. - -Optionally, add a script like the following: ---- -@echo off -rem Usage: cover filename [test_ suffix] # proper case required by coverage -rem filename without .py, 2nd parameter if test is not test_filename -setlocal -set py=f:\dev\3x\pcbuild\win32\python_d.exe -set src=idlelib.%1 -if "%2" EQU "" set tst=f:/dev/3x/Lib/idlelib/idle_test/test_%1.py -if "%2" NEQ "" set tst=f:/dev/ex/Lib/idlelib/idle_test/test_%2.py - -%py% -m coverage run --pylib --source=%src% %tst% -%py% -m coverage report --show-missing -%py% -m coverage html -start htmlcov\3x_Lib_idlelib_%1_py.html -rem Above opens new report; htmlcov\index.html displays report index ---- -The second parameter was needed for tests of module x not named test_x. -(There were several before modules were renamed, now only one.) \ No newline at end of file From 4ab6c0e06bff62c52bf96b48bd88d4a487c4f239 Mon Sep 17 00:00:00 2001 From: Terry Jan Reedy Date: Thu, 20 Jul 2017 17:20:31 -0400 Subject: [PATCH 3/4] bpo-28523: IDLE: Use 'color' instead of 'colour'. --- Lib/idlelib/configdialog.py | 108 ++++++++++++++++++------------------ 1 file changed, 54 insertions(+), 54 deletions(-) diff --git a/Lib/idlelib/configdialog.py b/Lib/idlelib/configdialog.py index c36f0f3f67bed0..e1c3923caed43f 100644 --- a/Lib/idlelib/configdialog.py +++ b/Lib/idlelib/configdialog.py @@ -261,7 +261,7 @@ def create_page_highlight(self): """Return frame of widgets for Highlighting tab. Tk Variables: - colour: Color of selected target. + color: Color of selected target. builtin_theme: Menu variable for built-in theme. custom_theme: Menu variable for custom theme. fg_bg_toggle: Toggle for foreground/background color. @@ -276,11 +276,11 @@ def create_page_highlight(self): Methods [attachment]: load_theme_cfg: Load current highlight colors. - get_colour: Invoke colorchooser [button_set_colour]. - set_colour_sample_binding: Call set_colour_sample [fg_bg_toggle]. + get_color: Invoke colorchooser [button_set_color]. + set_color_sample_binding: Call set_color_sample [fg_bg_toggle]. set_highlight_target: set fg_bg_toggle, set_color_sample(). - set_colour_sample: Set frame background to target. - on_new_colour_set: Set new color and add option. + set_color_sample: Set frame background to target. + on_new_color_set: Set new color and add option. paint_theme_sample: Recolor sample. get_new_theme_name: Get from popup. create_new_theme: Combine theme with changes and save. @@ -293,8 +293,8 @@ def create_page_highlight(self): frame frame_custom: LabelFrame (*)text_highlight_sample: Text - (*)frame_colour_set: Frame - button_set_colour: Button + (*)frame_color_set: Frame + button_set_color: Button (*)opt_menu_highlight_target: DynOptionMenu - highlight_target frame_fg_bg_toggle: Frame (*)radio_fg: Radiobutton - fg_bg_toggle @@ -329,7 +329,7 @@ def create_page_highlight(self): self.builtin_theme = StringVar(parent) self.custom_theme = StringVar(parent) self.fg_bg_toggle = BooleanVar(parent) - self.colour = StringVar(parent) + self.color = StringVar(parent) self.is_builtin_theme = BooleanVar(parent) self.highlight_target = StringVar(parent) @@ -374,20 +374,20 @@ def tem(event, elem=element): text.tag_bind( self.theme_elements[element][0], '', tem) text.config(state=DISABLED) - self.frame_colour_set = Frame(frame_custom, relief=SOLID, borderwidth=1) + self.frame_color_set = Frame(frame_custom, relief=SOLID, borderwidth=1) frame_fg_bg_toggle = Frame(frame_custom) - button_set_colour = Button( - self.frame_colour_set, text='Choose Colour for :', - command=self.get_colour, highlightthickness=0) + button_set_color = Button( + self.frame_color_set, text='Choose Color for :', + command=self.get_color, highlightthickness=0) self.opt_menu_highlight_target = DynOptionMenu( - self.frame_colour_set, self.highlight_target, None, + self.frame_color_set, self.highlight_target, None, highlightthickness=0) #, command=self.set_highlight_targetBinding self.radio_fg = Radiobutton( frame_fg_bg_toggle, variable=self.fg_bg_toggle, value=1, - text='Foreground', command=self.set_colour_sample_binding) + text='Foreground', command=self.set_color_sample_binding) self.radio_bg=Radiobutton( frame_fg_bg_toggle, variable=self.fg_bg_toggle, value=0, - text='Background', command=self.set_colour_sample_binding) + text='Background', command=self.set_color_sample_binding) self.fg_bg_toggle.set(1) button_save_custom_theme = Button( frame_custom, text='Save as New Custom Theme', @@ -414,11 +414,11 @@ def tem(event, elem=element): frame_custom.pack(side=LEFT, padx=5, pady=5, expand=TRUE, fill=BOTH) frame_theme.pack(side=LEFT, padx=5, pady=5, fill=Y) #frame_custom - self.frame_colour_set.pack(side=TOP, padx=5, pady=5, expand=TRUE, fill=X) + self.frame_color_set.pack(side=TOP, padx=5, pady=5, expand=TRUE, fill=X) frame_fg_bg_toggle.pack(side=TOP, padx=5, pady=0) self.text_highlight_sample.pack( side=TOP, padx=5, pady=5, expand=TRUE, fill=BOTH) - button_set_colour.pack(side=TOP, expand=TRUE, fill=X, padx=8, pady=4) + button_set_color.pack(side=TOP, expand=TRUE, fill=X, padx=8, pady=4) self.opt_menu_highlight_target.pack( side=TOP, expand=TRUE, fill=X, padx=8, pady=3) self.radio_fg.pack(side=LEFT, anchor=E) @@ -694,7 +694,7 @@ def attach_var_callbacks(self): self.font_name.trace_add('write', self.var_changed_font) self.font_bold.trace_add('write', self.var_changed_font) self.space_num.trace_add('write', self.var_changed_space_num) - self.colour.trace_add('write', self.var_changed_colour) + self.color.trace_add('write', self.var_changed_color) self.builtin_theme.trace_add('write', self.var_changed_builtin_theme) self.custom_theme.trace_add('write', self.var_changed_custom_theme) self.is_builtin_theme.trace_add('write', self.var_changed_is_builtin_theme) @@ -712,7 +712,7 @@ def remove_var_callbacks(self): "Remove callbacks to prevent memory leaks." for var in ( self.font_size, self.font_name, self.font_bold, - self.space_num, self.colour, self.builtin_theme, + self.space_num, self.color, self.builtin_theme, self.custom_theme, self.is_builtin_theme, self.highlight_target, self.keybinding, self.builtin_keys, self.custom_keys, self.are_keys_builtin, self.win_width, self.win_height, @@ -738,9 +738,9 @@ def var_changed_space_num(self, *params): value = self.space_num.get() changes.add_option('main', 'Indent', 'num-spaces', value) - def var_changed_colour(self, *params): + def var_changed_color(self, *params): "Process change to color choice." - self.on_new_colour_set() + self.on_new_color_set() def var_changed_builtin_theme(self, *params): """Process new builtin theme selection. @@ -1099,7 +1099,7 @@ def delete_custom_theme(self): self.activate_config_changes() self.set_theme_type() - def get_colour(self): + def get_color(self): """Handle button to select a new color for the target tag. If a new color is selected while using a builtin theme, a @@ -1107,23 +1107,23 @@ def get_colour(self): Attributes accessed: highlight_target - frame_colour_set + frame_color_set is_builtin_theme Attributes updated: - colour + color Methods: get_new_theme_name create_new_theme """ target = self.highlight_target.get() - prev_colour = self.frame_colour_set.cget('bg') - rgbTuplet, colour_string = tkColorChooser.askcolor( - parent=self, title='Pick new colour for : '+target, - initialcolor=prev_colour) - if colour_string and (colour_string != prev_colour): - # User didn't cancel and they chose a new colour. + prev_color = self.frame_color_set.cget('bg') + rgbTuplet, color_string = tkColorChooser.askcolor( + parent=self, title='Pick new color for : '+target, + initialcolor=prev_color) + if color_string and (color_string != prev_color): + # User didn't cancel and they chose a new color. if self.is_builtin_theme.get(): # Current theme is a built-in. message = ('Your changes will be saved as a new Custom Theme. ' 'Enter a name for your new Custom Theme below.') @@ -1132,20 +1132,20 @@ def get_colour(self): return else: # Create new custom theme based on previously active theme. self.create_new_theme(new_theme) - self.colour.set(colour_string) + self.color.set(color_string) else: # Current theme is user defined. - self.colour.set(colour_string) + self.color.set(color_string) - def on_new_colour_set(self): + def on_new_color_set(self): "Display sample of new color selection on the dialog." - new_colour=self.colour.get() - self.frame_colour_set.config(bg=new_colour) # Set sample. + new_color=self.color.get() + self.frame_color_set.config(bg=new_color) # Set sample. plane ='foreground' if self.fg_bg_toggle.get() else 'background' sample_element = self.theme_elements[self.highlight_target.get()][0] - self.text_highlight_sample.tag_config(sample_element, **{plane:new_colour}) + self.text_highlight_sample.tag_config(sample_element, **{plane:new_color}) theme = self.custom_theme.get() theme_element = sample_element + '-' + plane - changes.add_option('highlight', theme, theme_element, new_colour) + changes.add_option('highlight', theme, theme_element, new_color) def get_new_theme_name(self, message): "Return name of new theme from query popup." @@ -1258,7 +1258,7 @@ def set_highlight_target(self): fg_bg_toggle Methods: - set_colour_sample + set_color_sample Called from: var_changed_highlight_target @@ -1272,17 +1272,17 @@ def set_highlight_target(self): self.radio_fg.config(state=NORMAL) self.radio_bg.config(state=NORMAL) self.fg_bg_toggle.set(1) - self.set_colour_sample() + self.set_color_sample() - def set_colour_sample_binding(self, *args): + def set_color_sample_binding(self, *args): """Change color sample based on foreground/background toggle. Methods: - set_colour_sample + set_color_sample """ - self.set_colour_sample() + self.set_color_sample() - def set_colour_sample(self): + def set_color_sample(self): """Set the color of the frame background to reflect the selected target. Instance variables accessed: @@ -1292,13 +1292,13 @@ def set_colour_sample(self): text_highlight_sample Attributes updated: - frame_colour_set + frame_color_set """ - # Set the colour sample area. + # Set the color sample area. tag = self.theme_elements[self.highlight_target.get()][0] plane = 'foreground' if self.fg_bg_toggle.get() else 'background' - colour = self.text_highlight_sample.tag_cget(tag, plane) - self.frame_colour_set.config(bg=colour) + color = self.text_highlight_sample.tag_cget(tag, plane) + self.frame_color_set.config(bg=color) def paint_theme_sample(self): """Apply the theme colors to each element tag in the sample text. @@ -1313,7 +1313,7 @@ def paint_theme_sample(self): text_highlight_sample: Set the tag elements to the theme. Methods: - set_colour_sample + set_color_sample Called from: var_changed_builtin_theme @@ -1326,19 +1326,19 @@ def paint_theme_sample(self): theme = self.custom_theme.get() for element_title in self.theme_elements: element = self.theme_elements[element_title][0] - colours = idleConf.GetHighlight(theme, element) + colors = idleConf.GetHighlight(theme, element) if element == 'cursor': # Cursor sample needs special painting. - colours['background'] = idleConf.GetHighlight( + colors['background'] = idleConf.GetHighlight( theme, 'normal', fgBg='bg') # Handle any unsaved changes to this theme. if theme in changes['highlight']: theme_dict = changes['highlight'][theme] if element + '-foreground' in theme_dict: - colours['foreground'] = theme_dict[element + '-foreground'] + colors['foreground'] = theme_dict[element + '-foreground'] if element + '-background' in theme_dict: - colours['background'] = theme_dict[element + '-background'] - self.text_highlight_sample.tag_config(element, **colours) - self.set_colour_sample() + colors['background'] = theme_dict[element + '-background'] + self.text_highlight_sample.tag_config(element, **colors) + self.set_color_sample() def help_source_selected(self, event): "Handle event for selecting additional help." From 76aa59aa9c344be25083796feb6e4fec077abf95 Mon Sep 17 00:00:00 2001 From: Terry Jan Reedy Date: Fri, 21 Jul 2017 00:55:14 -0400 Subject: [PATCH 4/4] News blurb. --- Misc/NEWS.d/next/IDLE/2017-07-21-00-54-52.bpo-28523.OPcqYJ.rst | 1 + 1 file changed, 1 insertion(+) create mode 100644 Misc/NEWS.d/next/IDLE/2017-07-21-00-54-52.bpo-28523.OPcqYJ.rst diff --git a/Misc/NEWS.d/next/IDLE/2017-07-21-00-54-52.bpo-28523.OPcqYJ.rst b/Misc/NEWS.d/next/IDLE/2017-07-21-00-54-52.bpo-28523.OPcqYJ.rst new file mode 100644 index 00000000000000..d7c5f54c7c322e --- /dev/null +++ b/Misc/NEWS.d/next/IDLE/2017-07-21-00-54-52.bpo-28523.OPcqYJ.rst @@ -0,0 +1 @@ +IDLE: replace 'colour' with 'color' in configdialog.