From 11d5c710fd697f0196ff185ed37bf5c1208fa57c Mon Sep 17 00:00:00 2001 From: teknium1 <127238744+teknium1@users.noreply.github.com> Date: Wed, 23 Sep 2026 05:08:44 -0700 Subject: [PATCH] test(i18n): a served profile's turn binds the home override, not a mutated HERMES_HOME `test_language_is_per_profile_under_multiplex` switched profiles by rewriting `os.environ["HERMES_HOME"]` after `set_multiplex_active(True)`. That is the T1 standalone contract (environ IS the profile); a multiplexed turn binds `set_hermes_home_override`, and since the launch home is pinned at activation (#119242) a later env mutation is deliberately ignored. The two assertions are unchanged; only the profile-switch mechanism now matches production. --- tests/agent/test_i18n.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/tests/agent/test_i18n.py b/tests/agent/test_i18n.py index d319e42c72..8ab4476276 100644 --- a/tests/agent/test_i18n.py +++ b/tests/agent/test_i18n.py @@ -97,20 +97,24 @@ def test_language_is_per_profile_under_multiplex(monkeypatch, tmp_path): """HERMES_LANGUAGE in the DEFAULT profile's environ must not leak into a secondary profile's turn, and the config-language cache must not freeze one profile's ``display.language`` for all.""" from agent import secret_scope + from hermes_constants import reset_hermes_home_override, set_hermes_home_override default_home = tmp_path / "default"; default_home.mkdir() prof_b = tmp_path / "b"; prof_b.mkdir() (default_home / "config.yaml").write_text("display:\n language: fr\n") (prof_b / "config.yaml").write_text("display:\n language: de\n") monkeypatch.setenv("HERMES_LANGUAGE", "zh") # default profile's .env, bridged into environ + monkeypatch.setenv("HERMES_HOME", str(default_home)) i18n.reset_language_cache() - secret_scope.set_multiplex_active(True) + secret_scope.set_multiplex_active(True) # pins the launch home; a served turn binds an override token = secret_scope.set_secret_scope({}) try: - monkeypatch.setenv("HERMES_HOME", str(default_home)) assert i18n.get_language() == "fr" # scoped miss: env ignored, this profile's config wins - monkeypatch.setenv("HERMES_HOME", str(prof_b)) - assert i18n.get_language() == "de" # not the first profile's cached "fr" + home_token = set_hermes_home_override(prof_b) + try: + assert i18n.get_language() == "de" # not the first profile's cached "fr" + finally: + reset_hermes_home_override(home_token) finally: secret_scope.reset_secret_scope(token) secret_scope.set_multiplex_active(False)