summaryrefslogtreecommitdiffstats
path: root/Lib/distutils/tests
diff options
context:
space:
mode:
authorLarry Hastings <larry@hastings.org>2015-09-09 14:00:54 (GMT)
committerLarry Hastings <larry@hastings.org>2015-09-09 14:00:54 (GMT)
commit334b4a3403c3a120418cb42052ebfd9277d9b3b9 (patch)
tree5bf608b7bf82eebf36acfe507ccd945c955441be /Lib/distutils/tests
parent1030c10c882399a09b534a013b16012d2abf9c31 (diff)
parent52e40cd9ecfc815973583bdfff2ec8650e6114a1 (diff)
downloadcpython-334b4a3403c3a120418cb42052ebfd9277d9b3b9.zip
cpython-334b4a3403c3a120418cb42052ebfd9277d9b3b9.tar.gz
cpython-334b4a3403c3a120418cb42052ebfd9277d9b3b9.tar.bz2
Merge from 3.5.
Diffstat (limited to 'Lib/distutils/tests')
-rw-r--r--Lib/distutils/tests/test_msvccompiler.py61
1 files changed, 56 insertions, 5 deletions
diff --git a/Lib/distutils/tests/test_msvccompiler.py b/Lib/distutils/tests/test_msvccompiler.py
index 1f88907..c4d911f 100644
--- a/Lib/distutils/tests/test_msvccompiler.py
+++ b/Lib/distutils/tests/test_msvccompiler.py
@@ -16,22 +16,73 @@ class msvccompilerTestCase(support.TempdirManager,
unittest.TestCase):
def test_no_compiler(self):
+ import distutils._msvccompiler as _msvccompiler
# makes sure query_vcvarsall raises
# a DistutilsPlatformError if the compiler
# is not found
- from distutils._msvccompiler import _get_vc_env
- def _find_vcvarsall():
- return None
+ def _find_vcvarsall(plat_spec):
+ return None, None
- import distutils._msvccompiler as _msvccompiler
old_find_vcvarsall = _msvccompiler._find_vcvarsall
_msvccompiler._find_vcvarsall = _find_vcvarsall
try:
- self.assertRaises(DistutilsPlatformError, _get_vc_env,
+ self.assertRaises(DistutilsPlatformError,
+ _msvccompiler._get_vc_env,
'wont find this version')
finally:
_msvccompiler._find_vcvarsall = old_find_vcvarsall
+ def test_compiler_options(self):
+ import distutils._msvccompiler as _msvccompiler
+ # suppress path to vcruntime from _find_vcvarsall to
+ # check that /MT is added to compile options
+ old_find_vcvarsall = _msvccompiler._find_vcvarsall
+ def _find_vcvarsall(plat_spec):
+ return old_find_vcvarsall(plat_spec)[0], None
+ _msvccompiler._find_vcvarsall = _find_vcvarsall
+ try:
+ compiler = _msvccompiler.MSVCCompiler()
+ compiler.initialize()
+
+ self.assertIn('/MT', compiler.compile_options)
+ self.assertNotIn('/MD', compiler.compile_options)
+ finally:
+ _msvccompiler._find_vcvarsall = old_find_vcvarsall
+
+ def test_vcruntime_copy(self):
+ import distutils._msvccompiler as _msvccompiler
+ # force path to a known file - it doesn't matter
+ # what we copy as long as its name is not in
+ # _msvccompiler._BUNDLED_DLLS
+ old_find_vcvarsall = _msvccompiler._find_vcvarsall
+ def _find_vcvarsall(plat_spec):
+ return old_find_vcvarsall(plat_spec)[0], __file__
+ _msvccompiler._find_vcvarsall = _find_vcvarsall
+ try:
+ tempdir = self.mkdtemp()
+ compiler = _msvccompiler.MSVCCompiler()
+ compiler.initialize()
+ compiler._copy_vcruntime(tempdir)
+
+ self.assertTrue(os.path.isfile(os.path.join(
+ tempdir, os.path.basename(__file__))))
+ finally:
+ _msvccompiler._find_vcvarsall = old_find_vcvarsall
+
+ def test_vcruntime_skip_copy(self):
+ import distutils._msvccompiler as _msvccompiler
+
+ tempdir = self.mkdtemp()
+ compiler = _msvccompiler.MSVCCompiler()
+ compiler.initialize()
+ dll = compiler._vcruntime_redist
+ self.assertTrue(os.path.isfile(dll))
+
+ compiler._copy_vcruntime(tempdir)
+
+ self.assertFalse(os.path.isfile(os.path.join(
+ tempdir, os.path.basename(dll))))
+
def test_suite():
return unittest.makeSuite(msvccompilerTestCase)