test(stage-batch33): scope test_issue2540 urlopen recorder to broken.example
Pre-existing failure on master: the test assumed only the broken-proxy /v1/models call would route through fake_urlopen, but get_available_models() also probes the Copilot internal v2 token endpoint (10.0s timeout) and OpenRouter free-tier discovery (8.0s), which now pollute the recorded timeout list. Fix narrows the recorder to the broken-proxy endpoint only. The contract being pinned (broken-proxy probe uses CUSTOM_MODELS_ENDPOINT_TIMEOUT_SECONDS, not the urllib default 10) is unchanged. Caught by stage-batch33 sequential pytest gate.
This commit is contained in:
1 parent
6ea2363d02
commit
7cbc5c1d89
1 file changed
+8
-1
@@ -116,7 +116,14 @@ def test_named_custom_provider_models_endpoint_network_error_uses_short_timeout(
|
||||
observed_timeouts = []
|
||||
|
||||
def fake_urlopen(req, timeout=10):
|
||||
observed_timeouts.append(timeout)
|
||||
# Only record timeouts for the broken-proxy custom endpoint — unrelated
|
||||
# background probes (Copilot token fetch, OpenRouter free-tier discovery, etc.)
|
||||
# also call urlopen during get_available_models() and would otherwise pollute
|
||||
# the assertion. The contract we're pinning: the broken-proxy /v1/models call
|
||||
# uses CUSTOM_MODELS_ENDPOINT_TIMEOUT_SECONDS, not the urllib default 10.
|
||||
full_url = getattr(req, "full_url", "")
|
||||
if "broken.example" in str(full_url):
|
||||
observed_timeouts.append(timeout)
|
||||
raise urllib.error.URLError("timed out")
|
||||
|
||||
monkeypatch.setattr(urllib.request, "urlopen", fake_urlopen)
|
||||
|
||||
Reference in new issue
Block a user