bpo-31003: IDLE - Add more tests for General tab#2859
bpo-31003: IDLE - Add more tests for General tab#2859terryjreedy merged 11 commits intopython:masterpython/cpython:masterfrom
Conversation
Collect general tab functions together.
Adapt tests to new names and test all radiobuttons.
|
WIP: Preparation, now ready to add tests. Each chunk is a coherent diff, and I will try to continue that way. |
|
I think this is complete. |
Lib/idlelib/configdialog.py
Outdated
| helplist_item_remove: Command for button_helplist_remove. | ||
| update_user_help_changed_items: Fill in changes. | ||
| Enable users to provisionally change general options. | ||
| Load_general_cfg loads current values. Radiobuttons |
There was a problem hiding this comment.
Load_general_cfg -> load_general_cfg
There was a problem hiding this comment.
how about "loads current settings" ?
There was a problem hiding this comment.
I added 'Function' to sentence in FontTab docstring and copied the form here: "Function load_general_cfg intializes tk variables and helplist using idleConf."
Lib/idlelib/configdialog.py
Outdated
| update_user_help_changed_items: Fill in changes. | ||
| Enable users to provisionally change general options. | ||
| Load_general_cfg loads current values. Radiobuttons | ||
| startup_shell_on and startup_editor_on set var startup_edit. |
There was a problem hiding this comment.
IMO the tk_var should add startup_edit (backtick), otherwise I found that is hard to read the comment.
There was a problem hiding this comment.
I used 'sets var x_y' in the FontTab docstring. I tried Var instead of var. We could use 'tk variable' to be really explicit, but I was hoping 'var' or 'Var' as an abbreviation (StringVar, IntVar, etc) would be clear enough. I am going to push as is, but we can revisit this in 'extract class' issues where function docstring become class docstring. bpo-31004, bpo-31050
Lib/idlelib/configdialog.py
Outdated
| startup_shell_on and startup_editor_on set var startup_edit. | ||
| Radiobuttons save_ask_on and save_auto_on set var autosave. | ||
| Entry boxes win_width_int and win_height_int set var win_width | ||
| and win_height. Setting vars invokes var_changed_var_name |
There was a problem hiding this comment.
var_changed_varname (e.g. startup_edit -> var_changed_startup_edit)
There was a problem hiding this comment.
Change to "Setting var_name invokes the var_changed_var_name callback...", which I hope is clearer.
| "Load current configuration settings for the general options." | ||
| # Set startup state. | ||
| self.startup_edit.set(idleConf.GetOption( | ||
| 'main', 'General', 'editor-on-startup', default=0, type='bool')) |
There was a problem hiding this comment.
default=0 was changed (previous is default=1), does this change right?
There was a problem hiding this comment.
The default is only needed if config-main.def is corrupted, which should be never. The win size calls do not give a default. config-main.def currently has 0 and default in call, if given, should be same.
| self.kwds = kwds | ||
| if isinstance(self.result, BaseException): | ||
| raise self.result | ||
| elif self.return_self: |
There was a problem hiding this comment.
Do this need to suppress when isinstance(self.result, BaseException) is True?
There was a problem hiding this comment.
I am not sure what 'suppression' you are proposing, but I really want to be able to raise any exception. Calltip tests should include one with eval mocked with Func(BaseException) to raise BaseException. (see code).
| (*)radio_startup_edit: Radiobutton - startup_edit | ||
| (*)radio_startup_shell: Radiobutton - startup_edit | ||
| (*)startup_editor_on: Radiobutton - startup_edit | ||
| (*)startup_shell_on: Radiobutton - startup_edit |
There was a problem hiding this comment.
This is trivial, but with the rename (and since this is moving to its own class soon), I had been thinking about the variable being startup_window and then the two choices just being shell and editor.
There was a problem hiding this comment.
If we were starting fresh..., but we are not. We cannot change config-main.def.
[General]
editor-on-startup= 0
This is read as a boolean, and startup_editor should be BooleanVar, not IntVar.
What we show users When tests are merged, we can review code and layout. I intend to remove three top frame and change to:
Window to open at startup: O Shell O Editor
Initial size: Width [_] Height []
When run code in editor: ... (see bpo-19042 for possible change)
| (*)radio_save_ask: Radiobutton - autosave | ||
| (*)radio_save_auto: Radiobutton - autosave | ||
| (*)save_ask_on: Radiobutton - autosave | ||
| (*)save_auto_on: Radiobutton - autosave |
There was a problem hiding this comment.
Same here as above, I was hoping to simplify the names to autosave and the choices to prompt and noprompt.
| @@ -735,16 +737,16 @@ def create_page_general(self): | ||
| win_height_title = Label(frame_win_size, text='Height') | ||
| self.entry_win_height = Entry( | ||
| frame_win_size, textvariable=self.win_height, width=3) |
There was a problem hiding this comment.
You changed entry_win_height and entry_win_width in the comment, but not the code.
There was a problem hiding this comment.
With the issue mentioned on the ticket, would this help for validating the entry widget?
https://stackoverflow.com/questions/4140437/interactively-validating-entry-widget-content-in-tkinter#4140988
Lib/idlelib/configdialog.py
Outdated
| self.list_help.bind('<ButtonRelease-1>', self.help_source_selected) | ||
| scroll_helplist = Scrollbar(frame_helplist) | ||
| scroll_helplist.config(command=self.helplist.yview) | ||
| self.helplist.config(yscrollcommand=scroll_helplist.set) |
There was a problem hiding this comment.
Did you want to change config like you did for 'state'?
| for num in range(1, len(self.user_helplist) + 1): | ||
| changes.add_option( | ||
| 'main', 'HelpFiles', str(num), | ||
| ';'.join(self.user_helplist[num-1][:2])) |
There was a problem hiding this comment.
Would this be a good time to change it to for num, item in enumerate(self.user_helplist, 1): and the last line to .join(item[:2])?
in code and text, matching comment. (CSabella comment).
|
|
||
| Test that widget actions set vars, that var changes add three | ||
| options to changes and call set_samples, and that set_samples | ||
| changes the font of both sample boxes. |
There was a problem hiding this comment.
Too much text from Font test.
* In configdialog: Document causal pathways in create_page_general. Move related functions to follow this. Simplify some attribute names. * In test_configdialog: Add tests for load and helplist functions. Coverage for the general tab is now complete, and 63% overall. (cherry picked from commit 2bc8f0e)
* In configdialog: Document causal pathways in create_page_general. Move related functions to follow this. Simplify some attribute names. * In test_configdialog: Add tests for load and helplist functions. Coverage for the general tab is now complete, and 63% overall. (cherry picked from commit 2bc8f0e)
https://bugs.python.org/issue31003