Skip to content

Commit 8a3e388

Browse files
test: verify unknown Apple Silicon chips fall back gracefully
Adds a regression test confirming that chip variants not yet in cpu_power.csv (e.g. a future Apple M5) still resolve to the existing default per-thread power estimate instead of raising an error.
1 parent 7bab6a3 commit 8a3e388

1 file changed

Lines changed: 14 additions & 0 deletions

File tree

tests/test_cpu.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -613,6 +613,20 @@ def test_apple_m4_chips_have_correct_tdp(self):
613613
self.assertEqual(tdp.model, chip)
614614
self.assertEqual(tdp.tdp, expected_tdp)
615615

616+
def test_unknown_apple_chip_falls_back_gracefully(self):
617+
with (
618+
mock.patch(
619+
"codecarbon.core.cpu.detect_cpu_model",
620+
return_value="Apple M5 Pro",
621+
),
622+
mock.patch("codecarbon.core.cpu.is_psutil_available", return_value=True),
623+
mock.patch("codecarbon.core.cpu.count_cpus", return_value=10),
624+
):
625+
tdp = TDP()
626+
627+
self.assertEqual(tdp.model, "Apple M5 Pro")
628+
self.assertEqual(tdp.tdp, 10 * DEFAULT_POWER_PER_CORE)
629+
616630

617631
class TestResourceTrackerCPUTracking(unittest.TestCase):
618632
def test_set_cpu_tracking_skips_tdp_when_rapl_available(self):

0 commit comments

Comments
 (0)