mirror of
https://github.com/python/cpython.git
synced 2025-10-02 05:12:23 +00:00
bpo-30917: IDLE: Fix mock_config deepcopy to read_string (#2754)
Patch by LouieLu.
This commit is contained in:
parent
d81bea6520
commit
ed014f7e13
1 changed files with 11 additions and 5 deletions
|
@ -196,6 +196,8 @@ class IdleConfTest(unittest.TestCase):
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def setUpClass(cls):
|
def setUpClass(cls):
|
||||||
|
cls.config_string = {}
|
||||||
|
|
||||||
conf = config.IdleConf(_utest=True)
|
conf = config.IdleConf(_utest=True)
|
||||||
if __name__ != '__main__':
|
if __name__ != '__main__':
|
||||||
idle_dir = os.path.dirname(__file__)
|
idle_dir = os.path.dirname(__file__)
|
||||||
|
@ -203,10 +205,9 @@ class IdleConfTest(unittest.TestCase):
|
||||||
idle_dir = os.path.abspath(sys.path[0])
|
idle_dir = os.path.abspath(sys.path[0])
|
||||||
for ctype in conf.config_types:
|
for ctype in conf.config_types:
|
||||||
config_path = os.path.join(idle_dir, '../config-%s.def' % ctype)
|
config_path = os.path.join(idle_dir, '../config-%s.def' % ctype)
|
||||||
conf.defaultCfg[ctype] = config.IdleConfParser(config_path)
|
with open(config_path, 'r') as f:
|
||||||
conf.userCfg[ctype] = config.IdleUserConfParser(config_path)
|
cls.config_string[ctype] = f.read()
|
||||||
conf.LoadCfgFiles()
|
|
||||||
cls.conf = conf
|
|
||||||
cls.orig_warn = config._warn
|
cls.orig_warn = config._warn
|
||||||
config._warn = Func()
|
config._warn = Func()
|
||||||
|
|
||||||
|
@ -222,7 +223,12 @@ class IdleConfTest(unittest.TestCase):
|
||||||
|
|
||||||
Both default and user config used the same config-*.def
|
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
|
return conf
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue