[Bugfix] Preserve non-logitproc entry points in tests (#51097)

Signed-off-by: Tristan Rice <rice@fn.lc>

Tristan Rice committed Aug 10, 2026 at 15:14 UTC 98a4144a4197c2b96e4df7bfd9c386d4fbdb1f4f
2 files changed +36 -5
tests/v1/logits_processors/test_custom_offline.py
+28
@@ -1,9 +1,11 @@
1 # SPDX-License-Identifier: Apache-2.0
2 # SPDX-FileCopyrightText: Copyright contributors to the vLLM project
3 +import importlib.metadata
4 from typing import Any
5
6 import pytest
7
8 +import tests.v1.logits_processors.utils as logitproc_test_utils
9 from tests.utils import create_new_process_for_each_test, set_random_seed
10 from tests.v1.logits_processors.utils import (
11 DUMMY_LOGITPROC_ARG,
@@ -42,6 +44,32 @@ sampling_params_list = [
44 ]
45
46
47 +def test_fake_entrypoint_preserves_other_groups(monkeypatch):
48 + other_group_entrypoints = object()
49 + monkeypatch.setattr(
50 + importlib.metadata,
51 + "entry_points",
52 + lambda **kwargs: other_group_entrypoints,
53 + )
54 + monkeypatch.setattr(
55 + logitproc_test_utils, "requires_spawn_multiprocessing", lambda: False
56 + )
57 +
58 + setup_fake_entrypoint(monkeypatch)
59 +
60 + logitproc_entrypoints = importlib.metadata.entry_points(
61 + group=logitproc_test_utils.LOGITSPROCS_GROUP
62 + )
63 + assert logitproc_entrypoints.names == [
64 + logitproc_test_utils.DUMMY_LOGITPROC_ENTRYPOINT
65 + ]
66 + assert (
67 + importlib.metadata.entry_points(group="another.entrypoint.group")
68 + is other_group_entrypoints
69 + )
70 + assert importlib.metadata.entry_points() is other_group_entrypoints
71 +
72 +
73 def _run_test(kwargs: dict, logitproc_loaded: bool) -> None:
74 """Compare `LLM` instance initialized with specified `kwargs` against
75 reference `LLM` instance.
tests/v1/logits_processors/utils.py
+8 -5
@@ -234,11 +234,6 @@ def register_fake_entrypoint(monkeypatch) -> str:
234 return str(tmpdir)
235
236
237 -def fake_entry_points(group: str) -> EntryPoints:
238 - """Fake version of importlib.metadata.entry_points."""
239 - return EntryPoints(group)
240 -
241 -
237 def setup_fake_entrypoint(monkeypatch) -> None:
238 """Expose the dummy logitproc entrypoint for the current platform."""
239 if requires_spawn_multiprocessing():
@@ -248,5 +243,13 @@ def setup_fake_entrypoint(monkeypatch) -> None:
243
244 import importlib.metadata
245
246 + original_entry_points = importlib.metadata.entry_points
247 +
248 + def fake_entry_points(**kwargs):
249 + group = kwargs.get("group")
250 + if group == LOGITSPROCS_GROUP:
251 + return EntryPoints(group)
252 + return original_entry_points(**kwargs)
253 +
254 monkeypatch.setattr(importlib.metadata, "entry_points", fake_entry_points)
255 monkeypatch.setenv("VLLM_WORKER_MULTIPROC_METHOD", "fork")