Skip to content

Commit 9d1c656

Browse files
test: eagerly reset probe module caches between tests
Import GPU/CPU probe modules before clearing caches so lru_cache state does not leak across tests in the full suite. Co-authored-by: Cursor <cursoragent@cursor.com>
1 parent 248663b commit 9d1c656

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

tests/conftest.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,11 @@
88
@pytest.fixture(autouse=True)
99
def _reset_process_hardware_cache():
1010
"""Isolate hardware/TDP/GPU probe caches between tests."""
11+
# Import probe modules so clear_cache() can reset their lru_cache state.
12+
import codecarbon.core.cpu # noqa: F401
13+
import codecarbon.core.gpu_amd # noqa: F401
14+
import codecarbon.core.gpu_nvidia # noqa: F401
15+
import codecarbon.core.powermetrics # noqa: F401
1116
from codecarbon.core.util import detect_cpu_model
1217

1318
clear_hardware_cache()

0 commit comments

Comments
 (0)