Skip to content

bpo-30917: IDLE: Add config.IdleConf unittest #2691

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 22 commits into from
Jul 18, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
4d90afc
bpo-30917: IDLE: Add config.IdleConf unittest
mlouielu Jul 13, 2017
9fc7670
Add pragma to exclude coverage count
mlouielu Jul 13, 2017
d4dac80
Add unittest
mlouielu Jul 13, 2017
eb32d91
Add gui requires
mlouielu Jul 13, 2017
ddedbc7
Revert "Add pragma to exclude coverage count"
mlouielu Jul 15, 2017
06d8329
Add MacOS specific test correct
mlouielu Jul 15, 2017
f29e0da
Split get_user_config_dir to unix and windows
mlouielu Jul 15, 2017
3f2fdcc
Remove unused import
mlouielu Jul 15, 2017
e445a0e
Destroy tk.root after test cases end
mlouielu Jul 15, 2017
0f1607d
Add skipIf at get_user_cfg_dir test
mlouielu Jul 17, 2017
980a801
Update mock_config to deepcopy make it faster
mlouielu Jul 17, 2017
4ecfb1a
Add comment explain why put extra_help_source_list in same test
mlouielu Jul 18, 2017
d9b3702
Add disable extension to unittest
mlouielu Jul 18, 2017
511b726
Add get_keybinding unittest
mlouielu Jul 18, 2017
49e0534
Add save_user_cfg_files unittest
mlouielu Jul 18, 2017
7fba576
News blurb
terryjreedy Jul 18, 2017
206ae1e
supress warnintg, update coverage
terryjreedy Jul 18, 2017
c850b7f
Update 2017-07-17-23-35-57.bpo-30917.hSiuuO.rst
terryjreedy Jul 18, 2017
ef45060
Addressed terry's comments
mlouielu Jul 18, 2017
7627733
Put extra help source list input data reverse to check it is sorted
mlouielu Jul 18, 2017
2cbb960
Merge branch 'add_idleconf_unittest' of github.com:mlouielu/cpython i…
mlouielu Jul 18, 2017
c94d4b5
Remove sorted in RemoveKeyBindNames
mlouielu Jul 18, 2017
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 8 additions & 14 deletions Lib/idlelib/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import sys

from tkinter.font import Font
import idlelib

class InvalidConfigType(Exception): pass
class InvalidConfigSet(Exception): pass
Expand Down Expand Up @@ -159,14 +160,15 @@ class IdleConf:
for config_type in self.config_types:
(user home dir)/.idlerc/config-{config-type}.cfg
"""
def __init__(self):
def __init__(self, _utest=False):
self.config_types = ('main', 'highlight', 'keys', 'extensions')
self.defaultCfg = {}
self.userCfg = {}
self.cfg = {} # TODO use to select userCfg vs defaultCfg
self.CreateConfigHandlers()
self.LoadCfgFiles()

if not _utest:
self.CreateConfigHandlers()
self.LoadCfgFiles()

def CreateConfigHandlers(self):
"Populate default and user config parser dictionaries."
Expand Down Expand Up @@ -215,7 +217,8 @@ def GetUserCfgDir(self):
except OSError:
warn = ('\n Warning: unable to create user config directory\n' +
userDir + '\n Check path and permissions.\n Exiting!\n')
print(warn, file=sys.stderr)
if not idlelib.testing:
print(warn, file=sys.stderr)
raise SystemExit
# TODO continue without userDIr instead of exit
return userDir
Expand Down Expand Up @@ -463,16 +466,7 @@ def GetExtensions(self, active_only=True,

def RemoveKeyBindNames(self, extnNameList):
"Return extnNameList with keybinding section names removed."
# TODO Easier to return filtered copy with list comp
names = extnNameList
kbNameIndicies = []
for name in names:
if name.endswith(('_bindings', '_cfgBindings')):
kbNameIndicies.append(names.index(name))
kbNameIndicies.sort(reverse=True)
for index in kbNameIndicies: #delete each keybinding section name
del(names[index])
return names
return [n for n in extnNameList if not n.endswith(('_bindings', '_cfgBindings'))]

def GetExtnNameForEvent(self, virtualEvent):
"""Return the name of the extension binding virtualEvent, or None.
Expand Down
Loading