[BugFix][CI] Fix added _has_module tests (#44248)

Signed-off-by: Nick Hill <nickhill123@gmail.com>
This commit is contained in:
Nick Hill
2026-06-01 14:23:12 -07:00
committed by GitHub
parent 266b9d9c64
commit 6f8b40a23f
-36
View File
@@ -83,42 +83,6 @@ class TestHasModule:
): ):
assert _has_module("fake_native_ext") is False assert _has_module("fake_native_ext") is False
def test_returns_false_on_os_error_during_import(self):
"""Some shared-library failures surface as ``OSError``."""
fake_spec = MagicMock()
with (
patch(
"vllm.utils.import_utils.importlib.util.find_spec",
return_value=fake_spec,
),
patch(
"vllm.utils.import_utils.importlib.import_module",
side_effect=OSError("cannot load library"),
),
):
assert _has_module("fake_native_ext_os") is False
def test_returns_false_on_unexpected_error_during_import(self):
"""A broken extension may raise a non-import error (e.g. ``RuntimeError``).
Such modules are not usable, so ``_has_module`` should still return
``False`` rather than letting the exception propagate.
"""
fake_spec = MagicMock()
with (
patch(
"vllm.utils.import_utils.importlib.util.find_spec",
return_value=fake_spec,
),
patch(
"vllm.utils.import_utils.importlib.import_module",
side_effect=RuntimeError("CUDA driver version is insufficient"),
),
):
assert _has_module("fake_broken_ext") is False
def test_returns_false_when_find_spec_raises(self): def test_returns_false_when_find_spec_raises(self):
"""``find_spec`` itself can raise for dotted names whose parent package """``find_spec`` itself can raise for dotted names whose parent package
fails to import. This should be treated as the module being unavailable. fails to import. This should be treated as the module being unavailable.