summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJason R. Coombs <jaraco@jaraco.com>2020-09-05 10:45:35 -0400
committerJason R. Coombs <jaraco@jaraco.com>2020-09-05 10:56:41 -0400
commit37fa0e7531fbd240131d498f43436aafd4393149 (patch)
tree95f8ab61567c73329c27713c2009e74f4d711bdd
parent837fa5cd58e927953183e750d0c429a5e871865f (diff)
downloadpython-setuptools-git-37fa0e7531fbd240131d498f43436aafd4393149.tar.gz
Add test capturing failed expectation. Ref pypa/distutils#15.
-rw-r--r--distutils/tests/test_msvccompiler.py20
1 files changed, 20 insertions, 0 deletions
diff --git a/distutils/tests/test_msvccompiler.py b/distutils/tests/test_msvccompiler.py
index 88d912b1..46a51cd0 100644
--- a/distutils/tests/test_msvccompiler.py
+++ b/distutils/tests/test_msvccompiler.py
@@ -110,6 +110,26 @@ class TestSpawn(unittest.TestCase):
thread.join()
assert all(threads)
+ def test_concurrent_safe_fallback(self):
+ """
+ If CCompiler.spawn has been monkey-patched without support
+ for an env, it should still execute.
+ """
+ import distutils._msvccompiler as _msvccompiler
+ from distutils import ccompiler
+ compiler = _msvccompiler.MSVCCompiler()
+ compiler._paths = "expected"
+
+ def CCompiler_spawn(self, cmd):
+ "A spawn without an env argument."
+ assert os.environ["PATH"] == "expected"
+
+ with unittest.mock.patch.object(
+ ccompiler.CCompiler, 'spawn', CCompiler_spawn):
+ compiler.spawn(["n/a"])
+
+ assert os.environ.get("PATH") != "expected"
+
def test_suite():
return unittest.makeSuite(msvccompilerTestCase)