Skip to content

Commit d25b478

Browse files
cpcloudclaude
andcommitted
fix(core): handle driver-version failure in test helpers
Test helpers calling driver_version() at module scope would crash in no-driver environments before test collection. Mirror the production lazy-probe pattern: catch exceptions and pass None. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent d6edd32 commit d25b478

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

cuda_core/tests/test_linker.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,12 @@
2222

2323
def _current_env_backend() -> str:
2424
"""Return the backend a default (PTX input, no LTO) Linker picks on this machine."""
25+
try:
26+
drv_major = driver_version()[0]
27+
except Exception:
28+
drv_major = None
2529
return _linker._choose_backend(
26-
driver_version()[0],
30+
drv_major,
2731
_linker._probe_nvjitlink(),
2832
inputs_have_ltoir=False,
2933
lto_requested=False,

cuda_core/tests/test_program.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,12 @@
2020

2121
def _default_linker_backend() -> str:
2222
"""Backend a default (PTX input, no LTO) Linker picks on this machine."""
23+
try:
24+
drv_major = driver_version()[0]
25+
except Exception:
26+
drv_major = None
2327
return _linker._choose_backend(
24-
driver_version()[0],
28+
drv_major,
2529
_linker._probe_nvjitlink(),
2630
inputs_have_ltoir=False,
2731
lto_requested=False,

0 commit comments

Comments
 (0)