项目文件夹

文件
wehub-resource-sync eec33d25b2
Build Wheel / build (3.11) (push) Failing after 1s
Build Wheel / build (3.12) (push) Failing after 0s
pre-commit / pre-commit (push) Failing after 1s
chore: import upstream snapshot with attribution
2026-07-13 12:29:08 +08:00

32 行
1.0 KiB
Python

# SPDX-License-Identifier: Apache-2.0
# SPDX-FileCopyrightText: Copyright contributors to the vLLM project
"""Shared test helpers for video streaming tests."""
from __future__ import annotations
import io
import pytest
np = pytest.importorskip("numpy", reason="numpy required for video stream tests")
PIL = pytest.importorskip("PIL", reason="Pillow required for video stream tests")
from PIL import Image # noqa: E402
def make_jpeg(r: int = 128, g: int = 128, b: int = 128, size: int = 64) -> bytes:
"""Create a solid-colour JPEG image."""
img = Image.new("RGB", (size, size), (r, g, b))
buf = io.BytesIO()
img.save(buf, format="JPEG", quality=95)
return buf.getvalue()
def make_gradient_jpeg(seed: int, size: int = 64) -> bytes:
"""Create a random-gradient JPEG that varies based on *seed*."""
rng = np.random.RandomState(seed)
arr = rng.randint(0, 256, (size, size, 3), dtype=np.uint8)
img = Image.fromarray(arr, "RGB")
buf = io.BytesIO()
img.save(buf, format="JPEG", quality=95)
return buf.getvalue()