Sync from v0.13

This commit is contained in:
2026-01-19 10:38:50 +08:00
parent b2ef04d792
commit 5aef6c175a
3714 changed files with 854317 additions and 89342 deletions

View File

@@ -0,0 +1,46 @@
# SPDX-License-Identifier: Apache-2.0
# SPDX-FileCopyrightText: Copyright contributors to the vLLM project
import pytest
from vllm.utils.import_utils import PlaceholderModule
def _raises_module_not_found():
return pytest.raises(ModuleNotFoundError, match="No module named")
def test_placeholder_module_error_handling():
placeholder = PlaceholderModule("placeholder_1234")
with _raises_module_not_found():
int(placeholder)
with _raises_module_not_found():
placeholder()
with _raises_module_not_found():
_ = placeholder.some_attr
with _raises_module_not_found():
# Test conflict with internal __name attribute
_ = placeholder.name
# OK to print the placeholder or use it in a f-string
_ = repr(placeholder)
_ = str(placeholder)
# No error yet; only error when it is used downstream
placeholder_attr = placeholder.placeholder_attr("attr")
with _raises_module_not_found():
int(placeholder_attr)
with _raises_module_not_found():
placeholder_attr()
with _raises_module_not_found():
_ = placeholder_attr.some_attr
with _raises_module_not_found():
# Test conflict with internal __module attribute
_ = placeholder_attr.module