fix: skip display-dependent tests on headless CI
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:
@@ -1,5 +1,8 @@
|
||||
"""Tests for screen capture functionality."""
|
||||
|
||||
import os
|
||||
import sys
|
||||
|
||||
import numpy as np
|
||||
import pytest
|
||||
|
||||
@@ -14,7 +17,12 @@ from wled_controller.core.capture.screen_capture import (
|
||||
ScreenCapture,
|
||||
)
|
||||
|
||||
# Skip tests that require a real display on headless CI
|
||||
_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)")
|
||||
|
||||
|
||||
@requires_display
|
||||
def test_get_available_displays():
|
||||
"""Test getting available displays."""
|
||||
displays = get_available_displays()
|
||||
@@ -32,6 +40,7 @@ def test_get_available_displays():
|
||||
assert display.height > 0
|
||||
|
||||
|
||||
@requires_display
|
||||
def test_capture_display():
|
||||
"""Test capturing a display."""
|
||||
# Capture the first display
|
||||
@@ -46,6 +55,7 @@ def test_capture_display():
|
||||
assert capture.image.shape == (capture.height, capture.width, 3)
|
||||
|
||||
|
||||
@requires_display
|
||||
def test_capture_display_invalid_index():
|
||||
"""Test capturing with invalid display index."""
|
||||
with pytest.raises(ValueError):
|
||||
@@ -197,6 +207,7 @@ def test_calculate_color_empty_pixels():
|
||||
assert calculate_dominant_color(empty_pixels) == (0, 0, 0)
|
||||
|
||||
|
||||
@requires_display
|
||||
def test_end_to_end_screen_capture():
|
||||
"""Test complete screen capture workflow."""
|
||||
# Get available displays
|
||||
|
||||
Reference in New Issue
Block a user