test: isolate factory checks from developer proxy settings

This commit is contained in:
2026-09-09 01:27:25 -04:00
parent 8e61a66342
commit 71f1bdf26b
+7
View File
@@ -1068,6 +1068,13 @@ class TestManagedReasoningOwnership:
class TestDefaultClientFactory: class TestDefaultClientFactory:
"""直接检查生产 factory,不用取证测试的另一套 factory 代替。""" """直接检查生产 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"]) @pytest.mark.parametrize("key", ["fake-a", "fake-b"])
async def test_authorization_uses_source_api_key(self, key): async def test_authorization_uses_source_api_key(self, key):
from polygateway.transports.openai_compat import _default_client_factory from polygateway.transports.openai_compat import _default_client_factory