Skip to content

Commit 78bfa9e

Browse files
committed
test: enhance GPUAnalyzer tests with platform-specific mocks
1 parent 3e2beaa commit 78bfa9e

2 files changed

Lines changed: 9 additions & 2 deletions

File tree

tests/test_gpu.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import sys
21
import unittest
32
from unittest.mock import MagicMock, patch
43

tests/test_logic.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,12 +74,20 @@ def test_fetch_model_data_auth_error(
7474
self.assertTrue(found_tip, f"Tip not found in logs: {cm.output}")
7575

7676
@patch("canirun.logic.GPUAnalyzer")
77+
@patch("platform.machine")
78+
@patch("platform.system")
7779
@patch("psutil.virtual_memory")
78-
def test_get_specs_with_gpu(self, mock_vm: Any, MockGPU: Any) -> None:
80+
def test_get_specs_with_gpu(
81+
self, mock_vm: Any, mock_system: Any, mock_machine: Any, MockGPU: Any
82+
) -> None:
7983
"""Tests that _get_specs correctly prioritizes GPU over CPU/Mac."""
8084
# Setup RAM
8185
mock_vm.return_value.total = 32 * 1024**3
8286

87+
# Setup Linux Environment
88+
mock_system.return_value = "Linux"
89+
mock_machine.return_value = "x86_64"
90+
8391
# Setup GPU
8492
mock_gpu_instance = MockGPU.return_value
8593
mock_gpu_instance.is_gpu_available.return_value = True

0 commit comments

Comments
 (0)