Skip to content

Keep the developer's own settings out of the test suite - #35

Merged
dgsienko merged 2 commits into
dgsienko:mainfrom
bwets:fix/test-settings-isolation
Nov 20, 2026
Merged

dgsienko merged 2 commits into
dgsienko:mainfrom
bwets:fix/test-settings-isolation

Conversation

@bwets

@bwets bwets commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

Problem

app_state is built when diffui.server.state is imported, and AppState.__init__ reads settings.json at that moment, from the real ~/.config/diffui. The session fixture in conftest.py points _CONFIG_ROOT at a temp dir only afterwards, so the suite starts from whatever the developer saved: theme, editor, font size, word wrap, rebound keys.

Nothing on main fails from it today, but any test that depends on a display setting does. With #33 (All lines) for example, a developer who leaves All lines on gets two TUI failures, because the diff opens with the whole file instead of the hunks.

Fix

The session fixture calls app_state.__init__() right after patching _CONFIG_ROOT, so the settings are reloaded from the empty temp root. No production code changes.

Tests

test_settings_start_at_the_defaults_whatever_the_developer_saved checks that /api/settings reports what a fresh AppState loads from the test config root. It fails without the fixture change when $HOME/.config/diffui/settings.json holds non-default values, and passes with it.

pytest (323 passed) with a fake home holding non-default settings and with a real one, ruff check and ruff format --check are clean. On top of #33, with All lines saved on, the suite passes too (325).

AGENTS.md's Testing note mentions the reload. Version bumped to 0.12.1.

🤖 Generated with Claude Code

https://claude.ai/code/session_01Xshwvphn2wQmVKLLS2G9kJ

app_state is built when diffui.server.state is imported, and it reads
settings.json then, from the real ~/.config/diffui. The session fixture
points _CONFIG_ROOT at a temp dir only afterwards, so the developer's
theme, keybindings and display settings were what the tests started
from. The fixture now reloads app_state from the temp config root, and
a test checks the server starts at the defaults.

Bump version to 0.11.4

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Xshwvphn2wQmVKLLS2G9kJ
@bwets
bwets requested a review from dgsienko as a code owner November 20, 2026 16:05
@dgsienko
dgsienko merged commit 72496b9 into dgsienko:main Nov 20, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants