From d7680283a2780743e62e49523b29f48bc73ab115 Mon Sep 17 00:00:00 2001 From: Ethanfel Date: Thu, 18 Jun 2026 14:47:35 +0200 Subject: [PATCH] test: isolate QSettings in GUI tests so they never touch the real ~/.config/8cut Constructing MainWindow loads and (on close) re-saves the playlist tabs; a test that mutated tab state could persist into the user's real session. Redirect QSettings to a temp dir at import time. Co-Authored-By: Claude Fable 5 --- tests/test_ui_structure.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/tests/test_ui_structure.py b/tests/test_ui_structure.py index 1845e11..97cd9bd 100644 --- a/tests/test_ui_structure.py +++ b/tests/test_ui_structure.py @@ -1,5 +1,15 @@ import pytest +# Redirect QSettings to a throwaway dir BEFORE any MainWindow is constructed, so +# these GUI tests can never read or clobber the user's real ~/.config/8cut.conf +# (constructing MainWindow loads — and on window close re-saves — the playlist +# tabs; a test mutating tab state would otherwise persist into the real session). +import tempfile as _tempfile +from PyQt6.QtCore import QSettings as _QSettings +_QS_DIR = _tempfile.mkdtemp(prefix="8cut-test-qs-") +_QSettings.setPath(_QSettings.Format.NativeFormat, _QSettings.Scope.UserScope, _QS_DIR) +_QSettings.setPath(_QSettings.Format.IniFormat, _QSettings.Scope.UserScope, _QS_DIR) + # A real platform is needed because MpvWidget creates a GL context. # If construction fails for any environment reason, skip — this test is a # best-effort structural net, not a gate on core/ tests.