The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
test(model-metadata): use explicit fixture encodings
Teknium357b97eda6d1
diff --git a/tests/agent/test_model_metadata.py b/tests/agent/test_model_metadata.pyindex 7c36e14dda5..8d49a210781 100644--- a/tests/agent/test_model_metadata.py+++ b/tests/agent/test_model_metadata.py@@ -482,7 +482,9 @@ class TestCodexOAuthContextLength:assert ctx == live_contextmock_get.assert_called_once()- remaining = _yaml.safe_load(cache_file.read_text()).get("context_lengths", {})+ remaining = _yaml.safe_load(cache_file.read_text(encoding="utf-8")).get(+ "context_lengths", {}+ )assert remaining.get(stale_key) == live_contextassert remaining.get(other_key) == 128_000@@ -617,7 +619,7 @@ class TestNousPortalContextResolution:)assert ctx == 1_000_000, "OR fallback should still serve the request"assert not cache_file.exists() or not yaml.safe_load(- cache_file.read_text()+ cache_file.read_text(encoding="utf-8")).get("context_lengths", {}), ("OR-fallback values must NOT be persisted — a single portal blip ""would otherwise freeze the wrong value in via step-1 cache hit"@@ -659,7 +661,9 @@ class TestNousPortalContextResolution:f"Stale OR-derived cache entry should not have leaked through; got {ctx}")- remaining = yaml.safe_load(cache_file.read_text()).get("context_lengths", {})+ remaining = yaml.safe_load(cache_file.read_text(encoding="utf-8")).get(+ "context_lengths", {}+ )assert remaining.get(stale_key) == 262_144, ("Portal value should have overwritten the stale entry on disk")@@ -1117,7 +1121,7 @@ class TestContextLengthCache:"""``context_lengths:`` with no value parses as None — must behavelike an empty cache instead of crashing every caller (#47135)."""cache_file = tmp_path / "cache.yaml"- cache_file.write_text("context_lengths:\n")+ cache_file.write_text("context_lengths:\n", encoding="utf-8")with patch("agent.model_metadata._get_context_cache_path", return_value=cache_file):assert get_cached_context_length("test/model", "http://x") is None# save must also survive the null key and repair the file@@ -1131,7 +1135,7 @@ class TestContextLengthCache:with patch("agent.model_metadata._get_context_cache_path", return_value=cache_file):save_context_length("model", "http://x", 32768)save_context_length("model", "http://x", 32768)- with open(cache_file) as f:+ with open(cache_file, encoding="utf-8") as f:data = yaml.safe_load(f)assert len(data["context_lengths"]) == 1@@ -1219,7 +1223,7 @@ class TestMoAContextLength:payload["custom_providers"] = custom_providersif providers is not None:payload["providers"] = providers- with open(os.path.join(home, "config.yaml"), "w") as f:+ with open(os.path.join(home, "config.yaml"), "w", encoding="utf-8") as f:yaml.safe_dump(payload, f)def test_moa_resolves_from_aggregator(self, tmp_path, monkeypatch):