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: restore sys.modules after stub injection in langfuse otel test
Julio Quinteros Pro32922449a3f6
diff --git a/tests/test_litellm/integrations/test_langfuse_otel.py b/tests/test_litellm/integrations/test_langfuse_otel.pyindex ba4a096be24..62851b8f99f 100644--- a/tests/test_litellm/integrations/test_langfuse_otel.py+++ b/tests/test_litellm/integrations/test_langfuse_otel.py@@ -157,8 +157,12 @@ class TestLangfuseOtelIntegration:stub_module.LangFuseLogger = StubLFLogger # type: ignore- # Register stub in sys.modules so import inside method succeeds- sys.modules["litellm.integrations.langfuse.langfuse"] = stub_module # type: ignore+ # Register stub in sys.modules so import inside method succeeds.+ # Use monkeypatch so the real module is restored after the test runs,+ # preventing sys.modules corruption that would break patch() targets in+ # later tests (the patch would hit the stub while the real module's+ # globals remain unpatch-ed).+ monkeypatch.setitem(sys.modules, "litellm.integrations.langfuse.langfuse", stub_module) # type: ignorekwargs = {"litellm_params": {"metadata": {"foo": "bar"}}}extracted = LangfuseOtelLogger._extract_langfuse_metadata(kwargs)