The fastest, litest AI Gateway. Rust core with Python SDK. Call 100+ LLM APIs in OpenAI (or native) format with cost tracking, guardrails, load balancing, and logging [Bedrock, Azure, OpenAI, Anthropic, OpenAI, VertexAI, vLLM, Nvidia NIM]
Python ai-gatewayanthropicazure-openaibedrockgatewaylangchainlitellmllmllm-gatewayllmopsmcp-gatewayopenaiopenai-proxyrustrust-aivertex-ai
fix(token-counter): fix test isolation and encode() return type normalization
Julio Quinteros Profd1237e9af02
diff --git a/tests/test_litellm/litellm_core_utils/test_token_counter.py b/tests/test_litellm/litellm_core_utils/test_token_counter.pyindex a562e724665..0ce16de39f4 100644--- a/tests/test_litellm/litellm_core_utils/test_token_counter.py+++ b/tests/test_litellm/litellm_core_utils/test_token_counter.py@@ -582,14 +582,15 @@ class TestTokenizerSelection(unittest.TestCase):@patch("litellm.utils._return_huggingface_tokenizer")def test_disable_hf_tokenizer_download(self, mock_return_huggingface_tokenizer):- # Use pytest.MonkeyPatch() directly instead of fixturemonkeypatch = pytest.MonkeyPatch()monkeypatch.setattr(litellm, "disable_hf_tokenizer_download", True)-- result = _select_tokenizer_helper("grok-32r22r")- mock_return_huggingface_tokenizer.assert_not_called()- assert result["type"] == "openai_tokenizer"- assert result["tokenizer"] == encoding+ try:+ result = _select_tokenizer_helper("grok-32r22r")+ mock_return_huggingface_tokenizer.assert_not_called()+ assert result["type"] == "openai_tokenizer"+ assert result["tokenizer"] == encoding+ finally:+ monkeypatch.undo()@pytest.mark.parametrize(