@@ -136,6 +136,7 @@ def patched_run(*args, **kwargs):
136136 mock_run .assert_called_once_with (
137137 [sys .executable , "-m" , "pip" , "install" , "clang-format==20.1.7" ],
138138 capture_output = True ,
139+ text = True ,
139140 )
140141
141142
@@ -145,7 +146,7 @@ def test_install_tool_failure():
145146
146147 def patched_run (* args , ** kwargs ):
147148 return subprocess .CompletedProcess (
148- args , returncode = 1 , stderr = b "Error" , stdout = b "Installation failed"
149+ args , returncode = 1 , stderr = "Error" , stdout = "Installation failed"
149150 )
150151
151152 with (
@@ -159,7 +160,14 @@ def patched_run(*args, **kwargs):
159160@pytest .mark .benchmark
160161def test_install_tool_success_but_not_found ():
161162 """Test _install_tool when install succeeds but tool not found in PATH."""
162- with patch ("subprocess.run" ), patch ("shutil.which" , return_value = None ):
163+
164+ def patched_run (* args , ** kwargs ):
165+ return subprocess .CompletedProcess (args , returncode = 0 )
166+
167+ with (
168+ patch ("subprocess.run" , side_effect = patched_run ),
169+ patch ("shutil.which" , return_value = None ),
170+ ):
163171 result = _install_tool ("clang-format" , "20.1.7" )
164172 assert result is None
165173
0 commit comments