From: Vinay Sajip Date: Fri, 2 Mar 2012 01:24:13 +0000 (+0000) Subject: Closes #14158: merged test file resilience fix from 3.2. X-Git-Tag: v3.3.0a1~19 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=2f24d98df08fbed8e7c82a3de1843ef27b779739;p=python Closes #14158: merged test file resilience fix from 3.2. --- 2f24d98df08fbed8e7c82a3de1843ef27b779739 diff --cc Lib/test/regrtest.py index 871ae61183,714a116f87..44d3426f53 --- a/Lib/test/regrtest.py +++ b/Lib/test/regrtest.py @@@ -965,11 -887,11 +965,12 @@@ class saved_test_environment resources = ('sys.argv', 'cwd', 'sys.stdin', 'sys.stdout', 'sys.stderr', 'os.environ', 'sys.path', 'sys.path_hooks', '__import__', 'warnings.filters', 'asyncore.socket_map', - 'logging._handlers', 'logging._handlerList', - 'shutil.archive_formats', 'shutil.unpack_formats', + 'logging._handlers', 'logging._handlerList', 'sys.gettrace', 'sys.warnoptions', 'threading._dangling', 'multiprocessing.process._dangling', + 'sysconfig._CONFIG_VARS', 'sysconfig._SCHEMES', + 'packaging.command._COMMANDS', 'packaging.database_caches', + 'support.TESTFN', ) def get_sys_argv(self): @@@ -1143,26 -1022,20 +1144,40 @@@ multiprocessing.process._dangling.clear() multiprocessing.process._dangling.update(saved) + def get_sysconfig__CONFIG_VARS(self): + # make sure the dict is initialized + sysconfig.get_config_var('prefix') + return (id(sysconfig._CONFIG_VARS), sysconfig._CONFIG_VARS, + dict(sysconfig._CONFIG_VARS)) + def restore_sysconfig__CONFIG_VARS(self, saved): + sysconfig._CONFIG_VARS = saved[1] + sysconfig._CONFIG_VARS.clear() + sysconfig._CONFIG_VARS.update(saved[2]) + + def get_sysconfig__SCHEMES(self): + # it's mildly evil to look at the internal attribute, but it's easier + # than copying a RawConfigParser object + return (id(sysconfig._SCHEMES), sysconfig._SCHEMES._sections, + sysconfig._SCHEMES._sections.copy()) + def restore_sysconfig__SCHEMES(self, saved): + sysconfig._SCHEMES._sections = saved[1] + sysconfig._SCHEMES._sections.clear() + sysconfig._SCHEMES._sections.update(saved[2]) + + def get_support_TESTFN(self): + if os.path.isfile(support.TESTFN): + result = 'f' + elif os.path.isdir(support.TESTFN): + result = 'd' + else: + result = None + return result + def restore_support_TESTFN(self, saved_value): + if saved_value is None: + if os.path.isfile(support.TESTFN): + os.unlink(support.TESTFN) + elif os.path.isdir(support.TESTFN): + shutil.rmtree(support.TESTFN) def resource_info(self): for name in self.resources: