+++ /dev/null
-"""Tests for distutils.msvc9compiler."""\r
-import sys\r
-import unittest\r
-import os\r
-\r
-from distutils.errors import DistutilsPlatformError\r
-from distutils.tests import support\r
-from test.test_support import run_unittest\r
-\r
-_MANIFEST = """\\r
-<?xml version="1.0" encoding="UTF-8" standalone="yes"?>\r
-<assembly xmlns="urn:schemas-microsoft-com:asm.v1"\r
- manifestVersion="1.0">\r
- <trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">\r
- <security>\r
- <requestedPrivileges>\r
- <requestedExecutionLevel level="asInvoker" uiAccess="false">\r
- </requestedExecutionLevel>\r
- </requestedPrivileges>\r
- </security>\r
- </trustInfo>\r
- <dependency>\r
- <dependentAssembly>\r
- <assemblyIdentity type="win32" name="Microsoft.VC90.CRT"\r
- version="9.0.21022.8" processorArchitecture="x86"\r
- publicKeyToken="XXXX">\r
- </assemblyIdentity>\r
- </dependentAssembly>\r
- </dependency>\r
- <dependency>\r
- <dependentAssembly>\r
- <assemblyIdentity type="win32" name="Microsoft.VC90.MFC"\r
- version="9.0.21022.8" processorArchitecture="x86"\r
- publicKeyToken="XXXX"></assemblyIdentity>\r
- </dependentAssembly>\r
- </dependency>\r
-</assembly>\r
-"""\r
-\r
-_CLEANED_MANIFEST = """\\r
-<?xml version="1.0" encoding="UTF-8" standalone="yes"?>\r
-<assembly xmlns="urn:schemas-microsoft-com:asm.v1"\r
- manifestVersion="1.0">\r
- <trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">\r
- <security>\r
- <requestedPrivileges>\r
- <requestedExecutionLevel level="asInvoker" uiAccess="false">\r
- </requestedExecutionLevel>\r
- </requestedPrivileges>\r
- </security>\r
- </trustInfo>\r
- <dependency>\r
-\r
- </dependency>\r
- <dependency>\r
- <dependentAssembly>\r
- <assemblyIdentity type="win32" name="Microsoft.VC90.MFC"\r
- version="9.0.21022.8" processorArchitecture="x86"\r
- publicKeyToken="XXXX"></assemblyIdentity>\r
- </dependentAssembly>\r
- </dependency>\r
-</assembly>"""\r
-\r
-if sys.platform=="win32":\r
- from distutils.msvccompiler import get_build_version\r
- if get_build_version()>=8.0:\r
- SKIP_MESSAGE = None\r
- else:\r
- SKIP_MESSAGE = "These tests are only for MSVC8.0 or above"\r
-else:\r
- SKIP_MESSAGE = "These tests are only for win32"\r
-\r
-@unittest.skipUnless(SKIP_MESSAGE is None, SKIP_MESSAGE)\r
-class msvc9compilerTestCase(support.TempdirManager,\r
- unittest.TestCase):\r
-\r
- def test_no_compiler(self):\r
- # makes sure query_vcvarsall throws\r
- # a DistutilsPlatformError if the compiler\r
- # is not found\r
- from distutils.msvc9compiler import query_vcvarsall\r
- def _find_vcvarsall(version):\r
- return None\r
-\r
- from distutils import msvc9compiler\r
- old_find_vcvarsall = msvc9compiler.find_vcvarsall\r
- msvc9compiler.find_vcvarsall = _find_vcvarsall\r
- try:\r
- self.assertRaises(DistutilsPlatformError, query_vcvarsall,\r
- 'wont find this version')\r
- finally:\r
- msvc9compiler.find_vcvarsall = old_find_vcvarsall\r
-\r
- def test_reg_class(self):\r
- from distutils.msvc9compiler import Reg\r
- self.assertRaises(KeyError, Reg.get_value, 'xxx', 'xxx')\r
-\r
- # looking for values that should exist on all\r
- # windows registeries versions.\r
- path = r'Control Panel\Desktop'\r
- v = Reg.get_value(path, u'dragfullwindows')\r
- self.assertTrue(v in (u'0', u'1', u'2'))\r
-\r
- import _winreg\r
- HKCU = _winreg.HKEY_CURRENT_USER\r
- keys = Reg.read_keys(HKCU, 'xxxx')\r
- self.assertEqual(keys, None)\r
-\r
- keys = Reg.read_keys(HKCU, r'Control Panel')\r
- self.assertTrue('Desktop' in keys)\r
-\r
- def test_remove_visual_c_ref(self):\r
- from distutils.msvc9compiler import MSVCCompiler\r
- tempdir = self.mkdtemp()\r
- manifest = os.path.join(tempdir, 'manifest')\r
- f = open(manifest, 'w')\r
- try:\r
- f.write(_MANIFEST)\r
- finally:\r
- f.close()\r
-\r
- compiler = MSVCCompiler()\r
- compiler._remove_visual_c_ref(manifest)\r
-\r
- # see what we got\r
- f = open(manifest)\r
- try:\r
- # removing trailing spaces\r
- content = '\n'.join([line.rstrip() for line in f.readlines()])\r
- finally:\r
- f.close()\r
-\r
- # makes sure the manifest was properly cleaned\r
- self.assertEqual(content, _CLEANED_MANIFEST)\r
-\r
-\r
-def test_suite():\r
- return unittest.makeSuite(msvc9compilerTestCase)\r
-\r
-if __name__ == "__main__":\r
- run_unittest(test_suite())\r