Skip to content

bpo-30917: IDLE: Fix mock_config deepcopy to read_string #2754

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 1 commit into from
Jul 19, 2017
Merged
Changes from all commits
Commits
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
16 changes: 11 additions & 5 deletions Lib/idlelib/idle_test/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -196,17 +196,18 @@ class IdleConfTest(unittest.TestCase):

@classmethod
def setUpClass(cls):
cls.config_string = {}

conf = config.IdleConf(_utest=True)
if __name__ != '__main__':
idle_dir = os.path.dirname(__file__)
else:
idle_dir = os.path.abspath(sys.path[0])
for ctype in conf.config_types:
config_path = os.path.join(idle_dir, '../config-%s.def' % ctype)
conf.defaultCfg[ctype] = config.IdleConfParser(config_path)
conf.userCfg[ctype] = config.IdleUserConfParser(config_path)
conf.LoadCfgFiles()
cls.conf = conf
with open(config_path, 'r') as f:
cls.config_string[ctype] = f.read()

cls.orig_warn = config._warn
config._warn = Func()

Expand All @@ -222,7 +223,12 @@ def mock_config(self):

Both default and user config used the same config-*.def
"""
conf = copy.deepcopy(self.conf)
conf = config.IdleConf(_utest=True)
for ctype in conf.config_types:
conf.defaultCfg[ctype] = config.IdleConfParser('')
conf.defaultCfg[ctype].read_string(self.config_string[ctype])
conf.userCfg[ctype] = config.IdleUserConfParser('')
conf.userCfg[ctype].read_string(self.config_string[ctype])

return conf

Expand Down