diff options
author | Louie Lu <git@louie.lu> | 2017-07-19 23:27:06 (GMT) |
---|---|---|
committer | terryjreedy <tjreedy@udel.edu> | 2017-07-19 23:27:06 (GMT) |
commit | ed014f7e135fe021837208960237d6c37afde5be (patch) | |
tree | 61176e54b0270ea8071872438673c2e2153ea857 /Lib | |
parent | d81bea6520892e0428aec61c73e0631a69db11bb (diff) | |
download | cpython-ed014f7e135fe021837208960237d6c37afde5be.zip cpython-ed014f7e135fe021837208960237d6c37afde5be.tar.gz cpython-ed014f7e135fe021837208960237d6c37afde5be.tar.bz2 |
bpo-30917: IDLE: Fix mock_config deepcopy to read_string (#2754)
Patch by LouieLu.
Diffstat (limited to 'Lib')
-rw-r--r-- | Lib/idlelib/idle_test/test_config.py | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/Lib/idlelib/idle_test/test_config.py b/Lib/idlelib/idle_test/test_config.py index 197452d..5f23c8d 100644 --- a/Lib/idlelib/idle_test/test_config.py +++ b/Lib/idlelib/idle_test/test_config.py @@ -196,6 +196,8 @@ 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__) @@ -203,10 +205,9 @@ class IdleConfTest(unittest.TestCase): 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() @@ -222,7 +223,12 @@ class IdleConfTest(unittest.TestCase): 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 |