Skip to content

Commit e7dc437

Browse files
phernandezclaude
andcommitted
fix: use Path.home() mock for Windows compatibility in telemetry tests
The tests were setting the HOME environment variable, but on Windows Path.home() uses USERPROFILE instead. Mock Path.home() directly for cross-platform compatibility. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <[email protected]> Signed-off-by: phernandez <[email protected]>
1 parent 962f864 commit e7dc437

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

tests/test_telemetry.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ class TestGetInstallId:
1212

1313
def test_creates_install_id_on_first_call(self, tmp_path, monkeypatch):
1414
"""Test that a new install ID is created on first call."""
15-
monkeypatch.setenv("HOME", str(tmp_path))
15+
# Mock Path.home() to return tmp_path (works cross-platform)
16+
monkeypatch.setattr(Path, "home", lambda: tmp_path)
1617

1718
from basic_memory.telemetry import get_install_id
1819

@@ -29,7 +30,8 @@ def test_creates_install_id_on_first_call(self, tmp_path, monkeypatch):
2930

3031
def test_returns_existing_install_id(self, tmp_path, monkeypatch):
3132
"""Test that existing install ID is returned on subsequent calls."""
32-
monkeypatch.setenv("HOME", str(tmp_path))
33+
# Mock Path.home() to return tmp_path (works cross-platform)
34+
monkeypatch.setattr(Path, "home", lambda: tmp_path)
3335

3436
# Create the ID file first
3537
id_file = tmp_path / ".basic-memory" / ".install_id"

0 commit comments

Comments
 (0)