From 7b60f92a48b4ff54604e8179503488800866ca6f Mon Sep 17 00:00:00 2001 From: Warry Date: Mon, 29 Dec 2025 20:54:26 +0100 Subject: feat: Refactor playlist management, error handling, and testing infrastructure - Improved playlist item handling with pagination, error logging, and dedicated request hooks. - Consolidated reusable helpers for track ID normalization, playlist validation, and removal logic. - Enhanced error handling by introducing `PlaylistNotFound` and `UserNotAuthenticated` exceptions. - Refined Pytest `qapp` fixture for headless CI compatibility and session-scoped reuse. - Replaced redundant fixtures in multiple test files for consistency. - Improved playlist management GUI with detailed debug logging for notifications and operations. - Added `deptry` configuration to handle transitive dependencies and ignored exclusions. - Updated Pytest and Tox configurations for consistent environment setup during CI/CD runs. --- tests/conftest.py | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) (limited to 'tests/conftest.py') diff --git a/tests/conftest.py b/tests/conftest.py index 1e6cfe3..c85c444 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -1,3 +1,6 @@ +import os +import tempfile +from pathlib import Path from unittest.mock import Mock import pytest @@ -6,14 +9,24 @@ from tidalapi import Album, Track, Video from tidalapi.artist import Artist -@pytest.fixture -def qt_app(): - """Create a QApplication instance for testing Qt widgets.""" - app = QtWidgets.QApplication.instance() - if app is None: - app = QtWidgets.QApplication([]) +@pytest.fixture(scope="session") +def qapp(): + """Provide a QApplication configured for headless CI (offscreen/minimal).""" + # Ensure headless backend for CI runners + os.environ.setdefault("QT_QPA_PLATFORM", "offscreen") + # Qt expects XDG_RUNTIME_DIR to exist with correct permissions + runtime_dir = Path(tempfile.mkdtemp(prefix="xdg-runtime-")).resolve() + os.environ.setdefault("XDG_RUNTIME_DIR", str(runtime_dir)) + + # Lower graphical requirements + QtCore.QCoreApplication.setAttribute(QtCore.Qt.AA_DisableHighDpiScaling, True) + + app = QtWidgets.QApplication.instance() or QtWidgets.QApplication([]) yield app - # Note: don't quit the app as it may be shared across tests + + +# Backward compatible alias +qt_app = qapp @pytest.fixture -- cgit v1.3.1