[Test] Cleanup for helpers (#6523)

Signed-off-by: wangyu <410167048@qq.com>
Signed-off-by: [Your Name] <your.email@example.com>
Co-authored-by: amy-why-3459 <wuhaiyan17@huawei.com>
This commit is contained in:
wangyuandamy-why-3459 authored and GitHub committed 2026-08-25 09:10:17 +08:00
1 parent 8360346a66
commit 4af0ddc1c2
140 files changed
+4121 -4194

No files matched your search

@@ -0,0 +1,40 @@
# SPDX-License-Identifier: Apache-2.0
# SPDX-FileCopyrightText: Copyright contributors to the vLLM-Omni project
"""Tests for OmniRunner startup rollback."""
from __future__ import annotations
import pytest
from tests.helpers.runtime import OmniRunner
pytestmark = [pytest.mark.core_model, pytest.mark.cpu]
def test_runner_init_rolls_back_on_omni_startup_failure(monkeypatch: pytest.MonkeyPatch) -> None:
"""``__exit__`` is skipped when construction raises; rollback must still run."""
cleaned: list[str] = []
monkeypatch.setattr(
"tests.helpers.runtime.cleanup_test_environment",
lambda: cleaned.append("env"),
)
monkeypatch.setattr(
OmniRunner,
"_cleanup_process",
lambda self: cleaned.append("process"),
)
class _BoomOmni:
def __init__(self, *args, **kwargs) -> None:
raise RuntimeError("Orchestrator initialization failed")
monkeypatch.setattr("vllm_omni.entrypoints.omni.Omni", _BoomOmni)
with pytest.raises(RuntimeError, match="Orchestrator initialization failed"):
with OmniRunner("fake-model"):
raise AssertionError("context body must not run after a failed constructor")
assert cleaned.count("process") == 1
# Once at the start of ``__init__``, once from the constructor rollback.
assert cleaned.count("env") == 2