Skip to content

tests: isolate the home directory for the whole suite - #111

Merged
jothimani-rajendran merged 1 commit into
mainfrom
fix/test-home-isolation
Sep 7, 2026
Merged

jothimani-rajendran merged 1 commit into
mainfrom
fix/test-home-isolation

Conversation

@jothimani-rajendran

Copy link
Copy Markdown
Collaborator

What this changes

Running the suite no longer writes into the developer's real ~/.junie/config.json and ~/.kimi-code/config.toml. Closes #110.

Two tests in tests/test_install.py loop over every adapter with a repo_root under tmp_path, but junie and kimi_code keep their config under ~, so install() correctly expanded ~ and wrote a marked hook entry into the real home. A new autouse fixture in tests/conftest.py points every home variable at a per-test directory. It sets USERPROFILE and HOMEDRIVE + HOMEPATH as well as HOME, because ntpath.expanduser never reads HOME, so the existing per-test monkeypatch.setenv("HOME", ...) calls were leaving the Windows profile unprotected too.

No src/ change. Production install behaves exactly as its config path says.

Checks

  • pytest -q passes: 1523 passed, 4 skipped (3.11); 1521 passed, 6 skipped (3.10). Before each run ~/.junie and ~/.kimi-code were deleted, and after each run neither exists.
  • ruff check . and ruff format --check . pass
  • Runtime path is still stdlib-only (tests/check_stdlib_only.py passes)
  • Commits are signed off (git commit -s)

Notes for the reviewer

The fixture returns the home path, so a test that wants to assert on a user-scoped file can take isolated_home as an argument instead of re-deriving it. No existing test was changed; the per-test setenv("HOME") calls still work and now merely repeat what the fixture did.

🤖 Generated with Claude Code


Generated by Claude Code

Two install tests loop over every adapter with a repo_root under tmp_path,
but junie and kimi_code keep their config under `~`, so install() correctly
expanded `~` and wrote a hook entry into the developer's real ~/.junie and
~/.kimi-code. The junie-specific tests further down already moved HOME; the
loops did not.

An autouse fixture in conftest.py now points every home variable at a
per-test directory, so the next home-anchored vendor cannot leak the same
way. It sets USERPROFILE and HOMEDRIVE + HOMEPATH as well as HOME, since
ntpath.expanduser never reads HOME and the existing per-test setenv("HOME")
calls were leaving the Windows profile unprotected.

Closes #110.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Signed-off-by: Claude <noreply@anthropic.com>
@jothimani-rajendran
jothimani-rajendran marked this pull request as ready for review September 7, 2026 18:27
@jothimani-rajendran
jothimani-rajendran merged commit eb26dfa into main Sep 7, 2026
14 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.

Two install tests write into the real ~/.junie and ~/.kimi-code

2 participants