Skip to content

Commit 6864167

Browse files
committed
Use monkeypatch to monkeypatch.
1 parent 3dcdf85 commit 6864167

File tree

1 file changed

+7
-10
lines changed

1 file changed

+7
-10
lines changed

distutils/tests/test_msvccompiler.py

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,22 +14,19 @@
1414

1515

1616
class Testmsvccompiler(support.TempdirManager):
17-
def test_no_compiler(self):
17+
def test_no_compiler(self, monkeypatch):
1818
# makes sure query_vcvarsall raises
1919
# a DistutilsPlatformError if the compiler
2020
# is not found
2121
def _find_vcvarsall(plat_spec):
2222
return None, None
2323

24-
old_find_vcvarsall = _msvccompiler._find_vcvarsall
25-
_msvccompiler._find_vcvarsall = _find_vcvarsall
26-
try:
27-
with pytest.raises(DistutilsPlatformError):
28-
_msvccompiler._get_vc_env(
29-
'wont find this version',
30-
)
31-
finally:
32-
_msvccompiler._find_vcvarsall = old_find_vcvarsall
24+
monkeypatch.setattr(_msvccompiler, '_find_vcvarsall', _find_vcvarsall)
25+
26+
with pytest.raises(DistutilsPlatformError):
27+
_msvccompiler._get_vc_env(
28+
'wont find this version',
29+
)
3330

3431
@needs_winreg
3532
def test_get_vc_env_unicode(self):

0 commit comments

Comments
 (0)