Skip to content

The agent that grows with you

test(gateway): trim macOS proxy-cache tests to the two invariants

kshitijk4poor7bcaf554b0e7
diff --git a/tests/gateway/test_proxy_mode.py b/tests/gateway/test_proxy_mode.py
index 8c8d02607a3..67c6e0696f2 100644
--- a/tests/gateway/test_proxy_mode.py
+++ b/tests/gateway/test_proxy_mode.py
@@ -162,6 +162,7 @@ class TestResolveProxyUrl:
assert resolve_proxy_url(target_hosts=["149.154.167.220"]) is None
class TestMacosProxyProbeCache:
"""``scutil --proxy`` is a ~11 ms fork and resolve_proxy_url runs it on the SEND path —
per chunk of an outbound message and per media attachment."""
@@ -169,9 +170,8 @@ class TestMacosProxyProbeCache:
SCUTIL_OUT = "<dictionary> {\n HTTPEnable : 1\n HTTPProxy : 10.0.0.1\n HTTPPort : 3128\n}"
@pytest.fixture(autouse=True)
- def _isolate(self, monkeypatch):
+ def _isolate(self):
import gateway.platforms.base as base
- monkeypatch.setattr(base.sys, "platform", "darwin")
base.reset_macos_proxy_cache()
yield
base.reset_macos_proxy_cache()
@@ -201,31 +201,6 @@ class TestMacosProxyProbeCache:
base._detect_macos_system_proxy()
assert len(calls) == 2
- def test_a_failing_scutil_is_not_re_forked_every_call(self, monkeypatch):
- """A broken or slow scutil must not cost a fork per chunk either."""
- import gateway.platforms.base as base
- calls = []
-
- def boom(*a, **kw):
- calls.append(a)
- raise OSError("scutil unavailable")
- monkeypatch.setattr(base.subprocess, "check_output", boom)
- assert [base._detect_macos_system_proxy() for _ in range(5)] == [None] * 5
- assert len(calls) == 1
-
- def test_reset_forces_a_re_read(self, monkeypatch):
- base, calls = self._count_forks(monkeypatch)
- base._detect_macos_system_proxy()
- base.reset_macos_proxy_cache()
- base._detect_macos_system_proxy()
- assert len(calls) == 2
-
- def test_non_darwin_never_forks(self, monkeypatch):
- base, calls = self._count_forks(monkeypatch)
- monkeypatch.setattr(base.sys, "platform", "linux")
- assert base._detect_macos_system_proxy() is None
- assert calls == []
-
class TestRunAgentProxyDispatch:
"""Test that _run_agent() delegates to proxy when configured."""