@@ -133,7 +133,8 @@ def _nvidia_smi_output(cuda_version="12.8"):
133133def test_detect_gpu_no_nvidia ():
134134 """No NVIDIA GPU returns 'cpu'."""
135135 installer = Installer ("/tmp/test" )
136- with patch ("funasr_server.installer.subprocess.run" ,
136+ with patch ("funasr_server.installer.platform.system" , return_value = "Linux" ), \
137+ patch ("funasr_server.installer.subprocess.run" ,
137138 side_effect = FileNotFoundError ):
138139 assert installer ._detect_gpu () == "cpu"
139140
@@ -144,7 +145,8 @@ def test_detect_gpu_cuda_128():
144145 mock_result = MagicMock ()
145146 mock_result .returncode = 0
146147 mock_result .stdout = _nvidia_smi_output ("12.8" )
147- with patch ("funasr_server.installer.subprocess.run" , return_value = mock_result ):
148+ with patch ("funasr_server.installer.platform.system" , return_value = "Linux" ), \
149+ patch ("funasr_server.installer.subprocess.run" , return_value = mock_result ):
148150 assert installer ._detect_gpu () == "cu128"
149151
150152
@@ -154,7 +156,8 @@ def test_detect_gpu_cuda_124():
154156 mock_result = MagicMock ()
155157 mock_result .returncode = 0
156158 mock_result .stdout = _nvidia_smi_output ("12.4" )
157- with patch ("funasr_server.installer.subprocess.run" , return_value = mock_result ):
159+ with patch ("funasr_server.installer.platform.system" , return_value = "Linux" ), \
160+ patch ("funasr_server.installer.subprocess.run" , return_value = mock_result ):
158161 assert installer ._detect_gpu () == "cu124"
159162
160163
@@ -164,7 +167,8 @@ def test_detect_gpu_cuda_121():
164167 mock_result = MagicMock ()
165168 mock_result .returncode = 0
166169 mock_result .stdout = _nvidia_smi_output ("12.1" )
167- with patch ("funasr_server.installer.subprocess.run" , return_value = mock_result ):
170+ with patch ("funasr_server.installer.platform.system" , return_value = "Linux" ), \
171+ patch ("funasr_server.installer.subprocess.run" , return_value = mock_result ):
168172 assert installer ._detect_gpu () == "cu121"
169173
170174
@@ -174,7 +178,8 @@ def test_detect_gpu_cuda_118():
174178 mock_result = MagicMock ()
175179 mock_result .returncode = 0
176180 mock_result .stdout = _nvidia_smi_output ("11.8" )
177- with patch ("funasr_server.installer.subprocess.run" , return_value = mock_result ):
181+ with patch ("funasr_server.installer.platform.system" , return_value = "Linux" ), \
182+ patch ("funasr_server.installer.subprocess.run" , return_value = mock_result ):
178183 assert installer ._detect_gpu () == "cu118"
179184
180185
@@ -184,7 +189,8 @@ def test_detect_gpu_cuda_126():
184189 mock_result = MagicMock ()
185190 mock_result .returncode = 0
186191 mock_result .stdout = _nvidia_smi_output ("12.6" )
187- with patch ("funasr_server.installer.subprocess.run" , return_value = mock_result ):
192+ with patch ("funasr_server.installer.platform.system" , return_value = "Linux" ), \
193+ patch ("funasr_server.installer.subprocess.run" , return_value = mock_result ):
188194 assert installer ._detect_gpu () == "cu126"
189195
190196
@@ -194,7 +200,8 @@ def test_detect_gpu_cuda_too_old():
194200 mock_result = MagicMock ()
195201 mock_result .returncode = 0
196202 mock_result .stdout = _nvidia_smi_output ("10.2" )
197- with patch ("funasr_server.installer.subprocess.run" , return_value = mock_result ):
203+ with patch ("funasr_server.installer.platform.system" , return_value = "Linux" ), \
204+ patch ("funasr_server.installer.subprocess.run" , return_value = mock_result ):
198205 assert installer ._detect_gpu () == "cpu"
199206
200207
@@ -211,7 +218,8 @@ def test_detect_gpu_unparseable():
211218 mock_result = MagicMock ()
212219 mock_result .returncode = 0
213220 mock_result .stdout = b"some weird output without version"
214- with patch ("funasr_server.installer.subprocess.run" , return_value = mock_result ):
221+ with patch ("funasr_server.installer.platform.system" , return_value = "Linux" ), \
222+ patch ("funasr_server.installer.subprocess.run" , return_value = mock_result ):
215223 assert installer ._detect_gpu () == "cu128"
216224
217225
0 commit comments