From 71f1bdf26b67f052318762a8346bac341c856d28 Mon Sep 17 00:00:00 2001 From: iomgaa Date: Wed, 9 Sep 2026 01:27:25 -0400 Subject: [PATCH] test: isolate factory checks from developer proxy settings --- tests/unit/test_openai_compat.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/tests/unit/test_openai_compat.py b/tests/unit/test_openai_compat.py index 0fa3d0a..497b062 100644 --- a/tests/unit/test_openai_compat.py +++ b/tests/unit/test_openai_compat.py @@ -1068,6 +1068,13 @@ class TestManagedReasoningOwnership: class TestDefaultClientFactory: """直接检查生产 factory,不用取证测试的另一套 factory 代替。""" + @pytest.fixture(autouse=True) + def isolate_proxy_environment(self, monkeypatch): + """离线构造测试不继承开发机代理;仍真实验证 trust_env 传递。""" + for key in ("HTTP_PROXY", "HTTPS_PROXY", "ALL_PROXY", "NO_PROXY"): + monkeypatch.delenv(key, raising=False) + monkeypatch.delenv(key.lower(), raising=False) + @pytest.mark.parametrize("key", ["fake-a", "fake-b"]) async def test_authorization_uses_source_api_key(self, key): from polygateway.transports.openai_compat import _default_client_factory