test(hermes_cli): make test_default_path pass on native Windows
TestGetHermesHome.test_default_path asserted ~/.hermes unconditionally, but the native Windows default is %LOCALAPPDATA%\hermes (see hermes_constants._get_platform_default_hermes_home). Branch the assertion by platform so the test passes everywhere. Salvaged from PR #96003 by @Aoshi-Dev (the parse-guard half of that PR was superseded by #96169); authorship preserved.
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
"""Tests for hermes_cli configuration management."""
|
||||
|
||||
import os
|
||||
import sys
|
||||
from pathlib import Path
|
||||
from unittest.mock import patch
|
||||
|
||||
@@ -37,7 +38,18 @@ class TestGetHermesHome:
|
||||
with patch.dict(os.environ, {}, clear=False):
|
||||
os.environ.pop("HERMES_HOME", None)
|
||||
home = get_hermes_home()
|
||||
assert home == Path.home() / ".hermes"
|
||||
if sys.platform == "win32":
|
||||
# Windows default is %LOCALAPPDATA%\hermes — see
|
||||
# hermes_constants._get_platform_default_hermes_home.
|
||||
local_appdata = os.environ.get("LOCALAPPDATA", "").strip()
|
||||
base = (
|
||||
Path(local_appdata)
|
||||
if local_appdata
|
||||
else Path.home() / "AppData" / "Local"
|
||||
)
|
||||
assert home == base / "hermes"
|
||||
else:
|
||||
assert home == Path.home() / ".hermes"
|
||||
|
||||
|
||||
class TestEnsureHermesHome:
|
||||
|
||||
Reference in New Issue
Block a user