Skip to content

Commit e84ddec

Browse files
committed
Adds tests and removes do not merge comment.
1 parent 0901f64 commit e84ddec

2 files changed

Lines changed: 27 additions & 4 deletions

File tree

Lib/distutils/_msvccompiler.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,6 @@ def _find_vc2017():
6666
# initialize COM.
6767
all_packages = []
6868
def _getall():
69-
# DO NOT MERGE - faulthandler triggers on non-fatal exception 0x40010006
7069
all_packages.extend(_findvs.findall())
7170
t = threading.Thread(target=_getall)
7271
t.start()
@@ -78,7 +77,7 @@ def _getall():
7877
if not os.path.isdir(vc_dir):
7978
continue
8079
try:
81-
version = tuple(int(i) for i in version_str.partition('.'))
80+
version = tuple(int(i) for i in version_str.split('.'))
8281
except (ValueError, TypeError):
8382
continue
8483
if version > best_version:

Lib/distutils/tests/test_msvccompiler.py

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,12 +76,12 @@ def test_vcruntime_skip_copy(self):
7676
compiler = _msvccompiler.MSVCCompiler()
7777
compiler.initialize()
7878
dll = compiler._vcruntime_redist
79-
self.assertTrue(os.path.isfile(dll))
79+
self.assertTrue(os.path.isfile(dll), dll or "<None>")
8080

8181
compiler._copy_vcruntime(tempdir)
8282

8383
self.assertFalse(os.path.isfile(os.path.join(
84-
tempdir, os.path.basename(dll))))
84+
tempdir, os.path.basename(dll))), dll or "<None>")
8585

8686
def test_get_vc_env_unicode(self):
8787
import distutils._msvccompiler as _msvccompiler
@@ -101,6 +101,30 @@ def test_get_vc_env_unicode(self):
101101
if old_distutils_use_sdk:
102102
os.environ['DISTUTILS_USE_SDK'] = old_distutils_use_sdk
103103

104+
def test_get_vc2017(self):
105+
import distutils._msvccompiler as _msvccompiler
106+
107+
# This function cannot be mocked, so pass it if we find VS 2017
108+
# and mark it skipped if we do not.
109+
version, path = _msvccompiler._find_vc2017()
110+
if version:
111+
self.assertGreaterEqual(version, 15)
112+
self.assertTrue(os.path.isdir(path))
113+
else:
114+
raise unittest.SkipTest("VS 2017 is not installed")
115+
116+
def test_get_vc2015(self):
117+
import distutils._msvccompiler as _msvccompiler
118+
119+
# This function cannot be mocked, so pass it if we find VS 2015
120+
# and mark it skipped if we do not.
121+
version, path = _msvccompiler._find_vc2015()
122+
if version:
123+
self.assertGreaterEqual(version, 14)
124+
self.assertTrue(os.path.isdir(path))
125+
else:
126+
raise unittest.SkipTest("VS 2015 is not installed")
127+
104128
def test_suite():
105129
return unittest.makeSuite(msvccompilerTestCase)
106130

0 commit comments

Comments
 (0)