tests: keep the suite away from the developer's Login Items and autostart file - #2554
Merged
Merged
Conversation
…tart file `init_db()` saves every settings row, which fires the post_save hook that applies the autostart setting via `open_app_at_startup()`, and test_toggle_all_settings toggles that setting on and off. Every test session therefore removed any real Vorta.app Login Item on macOS (and left a stray "Python" one behind, since the "off" path only removes Vorta.app entries) and deleted ~/.config/autostart/vorta.desktop on Linux. Stub `open_app_at_startup` out in pytest_configure; test_autostart_linux uses the real function with XDG_CONFIG_HOME pointed at a temporary directory. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Running the test suite changes the developer's system:
init_db()saves every settings row (to refresh labels/tooltips). Each save fires thepost_savehook that applies theautostartsetting throughvorta.autostart.open_app_at_startup(). Every test session therefore callsopen_app_at_startup(False), which on macOS removes any realVorta.appentry from the user's Login Items and on Linux deletes the real~/.config/autostart/vorta.desktop.test_toggle_all_settingstoggles the autostart setting on and off. On macOS the "on" half registers the test interpreter'sPython.appas a Login Item, and the "off" half only removes items matchingVorta.app, so a stray "Python" Login Item is left behind.This stubs
open_app_at_startupout inpytest_configure(next to the existing D-Bus / DNS / Wi-Fi stubs) and letstest_autostart_linux, which is about that function, use the real one withXDG_CONFIG_HOMEpointed at a temporary directory.Related Issue
Noticed while working on #2551. No separate issue.
Motivation and Context
Tests must not edit the developer's Login Items or autostart configuration.
How Has This Been Tested?
pytest tests/unitrun against this branch — 264 passed, 7 skipped; Login Items verified unchanged before/after the run.QT_QPA_PLATFORM=offscreen, in a container):pytest tests/unit/test_misc.py -k "autostart or toggle_all"— 2 passed (test_autostart_linux, test_toggle_all_settings);$HOME/.config/autostartdid not exist afterwards.Types of changes
Checklist:
I provide my contribution under the terms of the license of this repository and I affirm the Developer Certificate of Origin.
🤖 Generated with Claude Code