fix: skip display-dependent tests on headless CI
Some checks failed
Lint & Test / test (push) Successful in 1m52s
Build Release / build-windows (push) Has been cancelled

Tests that call get_available_displays() or capture_display() require
a real display ($DISPLAY on Linux, always available on Windows/macOS).
Mark them with @requires_display to skip on headless CI instead of
failing with "$DISPLAY not set".

Affects: test_screen_capture.py (4 tests), test_api.py (1 test).
This commit is contained in:
2026-03-22 02:27:04 +03:00
parent 250ebcd105
commit eeb51fa4e7
2 changed files with 20 additions and 1 deletions

View File

@@ -1,11 +1,18 @@
"""Tests for API endpoints (public + authenticated)."""
import os
import sys
import pytest
from fastapi.testclient import TestClient
from wled_controller.main import app
from wled_controller import __version__
from wled_controller.config import get_config
_has_display = bool(os.environ.get("DISPLAY") or sys.platform == "win32" or sys.platform == "darwin")
requires_display = pytest.mark.skipif(not _has_display, reason="No display available (headless CI)")
client = TestClient(app)
# Build auth header from the first configured API key
@@ -41,8 +48,9 @@ def test_version_endpoint():
assert data["api_version"] == "v1"
@requires_display
def test_get_displays():
"""Test get displays endpoint (requires auth)."""
"""Test get displays endpoint (requires auth and a real display)."""
response = client.get("/api/v1/config/displays", headers=AUTH_HEADERS)
assert response.status_code == 200
data = response.json()