1 """Tests for distutils.msvc9compiler."""
6 from distutils
.errors
import DistutilsPlatformError
7 from distutils
.tests
import support
10 <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
11 <assembly xmlns="urn:schemas-microsoft-com:asm.v1"
12 manifestVersion="1.0">
13 <trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
16 <requestedExecutionLevel level="asInvoker" uiAccess="false">
17 </requestedExecutionLevel>
18 </requestedPrivileges>
23 <assemblyIdentity type="win32" name="Microsoft.VC90.CRT"
24 version="9.0.21022.8" processorArchitecture="x86"
25 publicKeyToken="XXXX">
31 <assemblyIdentity type="win32" name="Microsoft.VC90.MFC"
32 version="9.0.21022.8" processorArchitecture="x86"
33 publicKeyToken="XXXX"></assemblyIdentity>
39 _CLEANED_MANIFEST
= """\
40 <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
41 <assembly xmlns="urn:schemas-microsoft-com:asm.v1"
42 manifestVersion="1.0">
43 <trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
46 <requestedExecutionLevel level="asInvoker" uiAccess="false">
47 </requestedExecutionLevel>
48 </requestedPrivileges>
56 <assemblyIdentity type="win32" name="Microsoft.VC90.MFC"
57 version="9.0.21022.8" processorArchitecture="x86"
58 publicKeyToken="XXXX"></assemblyIdentity>
63 @unittest.skipUnless(sys
.platform
=="win32", "These tests are only for win32")
64 class msvc9compilerTestCase(support
.TempdirManager
,
67 def test_no_compiler(self
):
68 # makes sure query_vcvarsall throws
69 # a DistutilsPlatformError if the compiler
71 from distutils
.msvccompiler
import get_build_version
72 if get_build_version() < 8.0:
73 # this test is only for MSVC8.0 or above
75 from distutils
.msvc9compiler
import query_vcvarsall
76 def _find_vcvarsall(version
):
79 from distutils
import msvc9compiler
80 old_find_vcvarsall
= msvc9compiler
.find_vcvarsall
81 msvc9compiler
.find_vcvarsall
= _find_vcvarsall
83 self
.assertRaises(DistutilsPlatformError
, query_vcvarsall
,
84 'wont find this version')
86 msvc9compiler
.find_vcvarsall
= old_find_vcvarsall
88 def test_reg_class(self
):
89 from distutils
.msvccompiler
import get_build_version
90 if get_build_version() < 8.0:
91 # this test is only for MSVC8.0 or above
94 from distutils
.msvc9compiler
import Reg
95 self
.assertRaises(KeyError, Reg
.get_value
, 'xxx', 'xxx')
97 # looking for values that should exist on all
98 # windows registeries versions.
99 path
= r
'Control Panel\Desktop'
100 v
= Reg
.get_value(path
, u
'dragfullwindows')
101 self
.assertTrue(v
in (u
'0', u
'1', u
'2'))
104 HKCU
= _winreg
.HKEY_CURRENT_USER
105 keys
= Reg
.read_keys(HKCU
, 'xxxx')
106 self
.assertEquals(keys
, None)
108 keys
= Reg
.read_keys(HKCU
, r
'Control Panel')
109 self
.assertTrue('Desktop' in keys
)
111 def test_remove_visual_c_ref(self
):
112 from distutils
.msvc9compiler
import MSVCCompiler
113 tempdir
= self
.mkdtemp()
114 manifest
= os
.path
.join(tempdir
, 'manifest')
115 f
= open(manifest
, 'w')
119 compiler
= MSVCCompiler()
120 compiler
._remove
_visual
_c
_ref
(manifest
)
124 # removing trailing spaces
125 content
= '\n'.join([line
.rstrip() for line
in f
.readlines()])
128 # makes sure the manifest was properly cleaned
129 self
.assertEquals(content
, _CLEANED_MANIFEST
)
133 return unittest
.makeSuite(msvc9compilerTestCase
)
135 if __name__
== "__main__":
136 unittest
.main(defaultTest
="test_suite")