]> granicus.if.org Git - python/commitdiff
Branch merge
authorÉric Araujo <merwok@netwok.org>
Thu, 26 May 2011 14:35:14 +0000 (16:35 +0200)
committerÉric Araujo <merwok@netwok.org>
Thu, 26 May 2011 14:35:14 +0000 (16:35 +0200)
1  2 
Lib/sysconfig.py
Lib/test/test_sysconfig.py

Simple merge
index 5c84a7574093c872994719239e79e9cc2532c1ab,77c23648b18b3a9ee0f39aef8adeb4a718d8c1dc..96f75f282d095c315122093c9927cb24b63dbdf4
@@@ -20,12 -14,12 +14,12 @@@ from sysconfig import (get_paths, get_p
                         _get_default_scheme, _expand_vars,
                         get_scheme_names, get_config_var, _main)
  
++
  class TestSysConfig(unittest.TestCase):
  
      def setUp(self):
-         """Make a copy of sys.path"""
          super(TestSysConfig, self).setUp()
          self.sys_path = sys.path[:]
 -        self.makefile = None
          # patching os.uname
          if hasattr(os, 'uname'):
              self.uname = os.uname
@@@ -52,8 -46,9 +46,7 @@@
                  self._added_envvars.append(var)
  
      def tearDown(self):
-         """Restore sys.path"""
          sys.path[:] = self.sys_path
 -        if self.makefile is not None:
 -            os.unlink(self.makefile)
          self._cleanup_testfn()
          if self.uname is not None:
              os.uname = self.uname
              get_config_vars()['CFLAGS'] = ('-arch %s -isysroot '
                                             '/Developer/SDKs/MacOSX10.4u.sdk  '
                                             '-fno-strict-aliasing -fno-common '
--                                           '-dynamic -DNDEBUG -g -O3'%(arch,))
++                                           '-dynamic -DNDEBUG -g -O3' % arch)
  
--            self.assertEqual(get_platform(), 'macosx-10.4-%s'%(arch,))
++            self.assertEqual(get_platform(), 'macosx-10.4-%s' % arch)
  
          # linux debian sarge
          os.name = 'posix'
          self.assertEqual(my_platform, test_platform)
  
  
 +class MakefileTests(unittest.TestCase):
++
 +    @unittest.skipIf(sys.platform.startswith('win'),
 +                     'Test is not Windows compatible')
 +    def test_get_makefile_filename(self):
 +        makefile = sysconfig.get_makefile_filename()
 +        self.assertTrue(os.path.isfile(makefile), makefile)
 +
 +    def test_parse_makefile(self):
 +        self.addCleanup(unlink, TESTFN)
 +        with open(TESTFN, "w") as makefile:
 +            print("var1=a$(VAR2)", file=makefile)
 +            print("VAR2=b$(var3)", file=makefile)
 +            print("var3=42", file=makefile)
 +            print("var4=$/invalid", file=makefile)
 +            print("var5=dollar$$5", file=makefile)
 +        vars = sysconfig._parse_makefile(TESTFN)
 +        self.assertEqual(vars, {
 +            'var1': 'ab42',
 +            'VAR2': 'b42',
 +            'var3': 42,
 +            'var4': '$/invalid',
 +            'var5': 'dollar$5',
 +        })
 +
 +
  def test_main():
 -    run_unittest(TestSysConfig)
 +    run_unittest(TestSysConfig, MakefileTests)
  
  if __name__ == "__main__":
      test_main()