Repository navigation
fix: isolate completion test from local .pt-snap/focus.json - #53
Merged
Merged
Conversation
test_returns_empty_for_no_db fails when a local .pt-snap/focus.json exists because _resolve_db_for_completion() finds it via upward directory search. Fix by chdir-ing to a clean tmp_path. Fixes #52
codeasier
force-pushed
the
fix/completion-test-returns-empty-for-no-db
branch
from
April 18, 2026 15:39
a847f61 to
95d14c9
Compare
This was referenced Sep 6, 2026
codeasier
added a commit
that referenced
this pull request
Sep 17, 2026
…son (#124) Config.resolve_focus() walks up from the current directory looking for .pt-snap/focus.json, but the autouse fixture in tests/test_api.py only neutralized PT_SNAP_DB_PATH and Path.home(). A focus file written to the repository root by `pt-snap focus` or `pt-snap import` therefore leaked into test_set_focus_device_requires_database, which expected no database to be configured. Switch the fixture to monkeypatch and chdir into tmp_path, matching the isolation already used by every other CLI/MCP/service test module since #53, and add a test that pins the invariant that a fresh analyzer sees no inherited focus. Fixes #117 Co-authored-by: codeasier <liuyekang@huawei.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
test_returns_empty_for_no_dbfails when a local.pt-snap/focus.jsonexists because_resolve_db_for_completion()finds it via upward directory search fromPath.cwd().Fix: use
monkeypatch.chdir(tmp_path)to isolate the test in a clean temporary directory with no focus file.🔗 Related Issue
Fixes #52
🧪 Testing
ruff check .,black --check .)✅ Checklist
📋 Additional Notes
Single file change in
tests/test_completion.py.