Skip to content

Commit ed014f7

Browse files
mlouieluterryjreedy
authored andcommitted
bpo-30917: IDLE: Fix mock_config deepcopy to read_string (#2754)
Patch by LouieLu.
1 parent d81bea6 commit ed014f7

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

Lib/idlelib/idle_test/test_config.py

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -196,17 +196,18 @@ class IdleConfTest(unittest.TestCase):
196196

197197
@classmethod
198198
def setUpClass(cls):
199+
cls.config_string = {}
200+
199201
conf = config.IdleConf(_utest=True)
200202
if __name__ != '__main__':
201203
idle_dir = os.path.dirname(__file__)
202204
else:
203205
idle_dir = os.path.abspath(sys.path[0])
204206
for ctype in conf.config_types:
205207
config_path = os.path.join(idle_dir, '../config-%s.def' % ctype)
206-
conf.defaultCfg[ctype] = config.IdleConfParser(config_path)
207-
conf.userCfg[ctype] = config.IdleUserConfParser(config_path)
208-
conf.LoadCfgFiles()
209-
cls.conf = conf
208+
with open(config_path, 'r') as f:
209+
cls.config_string[ctype] = f.read()
210+
210211
cls.orig_warn = config._warn
211212
config._warn = Func()
212213

@@ -222,7 +223,12 @@ def mock_config(self):
222223
223224
Both default and user config used the same config-*.def
224225
"""
225-
conf = copy.deepcopy(self.conf)
226+
conf = config.IdleConf(_utest=True)
227+
for ctype in conf.config_types:
228+
conf.defaultCfg[ctype] = config.IdleConfParser('')
229+
conf.defaultCfg[ctype].read_string(self.config_string[ctype])
230+
conf.userCfg[ctype] = config.IdleUserConfParser('')
231+
conf.userCfg[ctype].read_string(self.config_string[ctype])
226232

227233
return conf
228234

0 commit comments

Comments
 (0)