bpo-30779: IDLE -- Factor ConfigChanges class from configdialog, put in config; test.#2612
bpo-30779: IDLE -- Factor ConfigChanges class from configdialog, put in config; test.#2612terryjreedy merged 15 commits intopython:masterfrom
Conversation
|
@terryjreedy, thanks for your PR! By analyzing the history of the files in this pull request, we identified @csabella, @asvetlov and @kbkaiser to be potential reviewers. |
mlouielu
left a comment
There was a problem hiding this comment.
Some method name need to consider to changed.
| configpage.remove_section(section) | ||
| configpage.Save() | ||
|
|
||
|
|
There was a problem hiding this comment.
Please remove one blank line
There was a problem hiding this comment.
Done. I appreciate the review. Polishing a patch is really hard.
| value -- value for the item. | ||
|
|
||
| Methods | ||
| add_item: |
There was a problem hiding this comment.
Would you prefer to use add_item in above changes? Current code is using additem.
There was a problem hiding this comment.
After reviewing configparser parameters, changed to add_option. Will have to change all in test and configdialog and check its tests.
|
|
||
| Methods | ||
| add_item: | ||
| save_all: Save all the changes to the config file. |
There was a problem hiding this comment.
Need to add set_value document (will dev use this method alone?)
| page[section][item] = value | ||
|
|
||
| @staticmethod | ||
| def set_value(config_type, section, item, value): |
There was a problem hiding this comment.
How about using save_item for consistency?
There was a problem hiding this comment.
save_option for consistency with add_option and save_all ;-). Only called in save_all,and twice in tests.
| for config_type in ['keys', 'highlight']: | ||
| # Save these even if unchanged! | ||
| idleConf.userCfg[config_type].Save() | ||
| self.clear() |
There was a problem hiding this comment.
Should the result be clear after save_all?
If should, then the docstring need to note it.
But I think it should not clear after save_all, this should let dev to do when needed
There was a problem hiding this comment.
Ah, it should be clear after save_all, that mean the changed has been apply. Maybe this side-affect need to be documented.
There was a problem hiding this comment.
By our current standard, yes. Changed.
| def tearDownModule(): | ||
| global root, configure | ||
| idleConf.userCfg = testcfg | ||
| idleConf.userCfg = usercfg |
There was a problem hiding this comment.
I think you should rebase/merge master branch since this changed has been merged into via PR #2606.
There was a problem hiding this comment.
I though maybe I branched after fetching that. Anyway, I fetched again, pushed master to origin, and
ran <git merge origin/master>, from the devguide, which has worked before. and pushed.
... Above -+ is gone from new diff.
| def __init__(self): | ||
| "Create a page for each configuration file" | ||
| self.pages = [] # List of unhashable dicts. | ||
| for config_type in ('main', 'highlight', 'keys', 'extensions'): |
There was a problem hiding this comment.
Question on the tuple ('main', 'highlight', 'keys', 'extensions')
This is in the IdleConf.__init__:
self.config_types = ('main', 'extensions', 'highlight', 'keys')
Any benefit to making that a module constant?
There was a problem hiding this comment.
I left it as idleConf attribute and used the attribute here to eliminate the duplication. Good catch.
| self.changed_items[typ][section][item] = value | ||
| changes.add_option('main', 'EditorWindow', 'encoding', value) | ||
|
|
||
| def GetDefaultItems(self): |
There was a problem hiding this comment.
I can't find GetDefaultItems used anywhere. Should it be removed?
There was a problem hiding this comment.
I grepped the file for 'default' to make sure you had not changed the name elsewhere to somethingdefaultsomething. 55 hit, not orphan function call. My guess is that someone wrote this, possibly for the check in save_option, and someone (same or other) decided to stick with idleConf instead of the skeletal duplicate, but did not remove.
I removed it in a separate commit.
|
|
||
| def add_option(self, config_type, section, item, value): | ||
| "Add item/value pair for config_type and section." | ||
| page = self[config_type] |
There was a problem hiding this comment.
I didn't know if we needed to add a check for config_type to make sure it's valid before accessing it.
There was a problem hiding this comment.
What would add_option do if it did? It expects new sections. New config-types are a bug. A test of the user, config dialog, should fail. General principle: only check first or catch after if one has an alternative action in mind that is better than letting an exception bubble up.
|
|
||
| def test_clear(self): | ||
| changes = self.load() | ||
| changes.clear() |
There was a problem hiding this comment.
Test_add_option verifies that load loads something. I added a comment to def load...
…, put in config; test. (pythonGH-2612) * In config, put dump test code in a function; run it and unittest in 'if __name__ == '__main__'. * Add class config.ConfigChanges based on changes_class_v4.py on bpo issue. * Add class test_config.ChangesTest, partly based on configdialog_tests_v1.py on bpo issue. * Revise configdialog to use ConfigChanges, mostly as specified in tracker msg297804. * Revise test_configdialog to match configdialog changes. All tests pass in both files. * Remove configdialog functions unused or moved to ConfigChanges. Cheryl Sabella contributed parts of the patch. (cherry picked from commit 349abd9)
…, put in config; test. (GH-2612) (#2625) * In config, put dump test code in a function; run it and unittest in 'if __name__ == '__main__'. * Add class config.ConfigChanges based on changes_class_v4.py on bpo issue. * Add class test_config.ChangesTest, partly based on configdialog_tests_v1.py on bpo issue. * Revise configdialog to use ConfigChanges, mostly as specified in tracker msg297804. * Revise test_configdialog to match configdialog changes. All tests pass in both files. * Remove configdialog functions unused or moved to ConfigChanges. Cheryl Sabella contributed parts of the patch. (cherry picked from commit 349abd9)
No description provided.