]> granicus.if.org Git - python/commitdiff
Closes #14158: merged test file resilience fix from 3.2.
authorVinay Sajip <vinay_sajip@yahoo.co.uk>
Fri, 2 Mar 2012 01:24:13 +0000 (01:24 +0000)
committerVinay Sajip <vinay_sajip@yahoo.co.uk>
Fri, 2 Mar 2012 01:24:13 +0000 (01:24 +0000)
1  2 
Lib/test/regrtest.py
Lib/test/test_base64.py
Lib/test/test_mailbox.py

index 871ae61183be76d6bca1719eb8d3be8da1c182f0,714a116f87d5d13bc613c7cbe9280742960860ee..44d3426f53c5ade17c46a7bec739e21653d53051
@@@ -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):
          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:
Simple merge
Simple merge