Skip to content

The agent that grows with you

test(profiles): bind the fake gateway_windows on the package too (#97897 class)

teknium107aad347be8e
diff --git a/tests/hermes_cli/test_profile_service_cleanup_scopes.py b/tests/hermes_cli/test_profile_service_cleanup_scopes.py
index ca8b2c4700b..b807f4de215 100644
--- a/tests/hermes_cli/test_profile_service_cleanup_scopes.py
+++ b/tests/hermes_cli/test_profile_service_cleanup_scopes.py
@@ -63,6 +63,10 @@ def test_cleanup_deletes_the_windows_scheduled_task(victim, tmp_path, monkeypatc
_legacy_startup_entry_path=lambda: tmp_path / "Startup" / "legacy.vbs",
)
monkeypatch.setitem(sys.modules, "hermes_cli.gateway_windows", fake)
+ # `from hermes_cli import gateway_windows` reads the package attribute first when an earlier
+ # test already imported the real module, so the fake must be bound there too.
+ import hermes_cli
+ monkeypatch.setattr(hermes_cli, "gateway_windows", fake, raising=False)
import platform
monkeypatch.setattr(platform, "system", lambda: "Windows")