Skip to content

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]

fix(test): restore Langfuse client counter in test cleanup

Julio Quinteros Pro679a0293bd9a
diff --git a/tests/test_litellm/integrations/test_langfuse.py b/tests/test_litellm/integrations/test_langfuse.py
index 15f252a4afc..cd3d5b9ebe3 100644
--- a/tests/test_litellm/integrations/test_langfuse.py
+++ b/tests/test_litellm/integrations/test_langfuse.py
@@ -21,6 +21,9 @@ from litellm.types.integrations.langfuse import *
class TestLangfuseUsageDetails(unittest.TestCase):
def setUp(self):
+ # Save global Langfuse client counter to restore after test
+ self._original_langfuse_clients_count = litellm.initialized_langfuse_clients
+
# Set up environment variables for testing
self.env_patcher = patch.dict(
"os.environ",
@@ -130,6 +133,9 @@ class TestLangfuseUsageDetails(unittest.TestCase):
# Delete logger instance to ensure complete cleanup
del self.logger
+ # Restore global Langfuse client counter to prevent cross-test pollution
+ litellm.initialized_langfuse_clients = self._original_langfuse_clients_count
+
self.env_patcher.stop()
self.langfuse_module_patcher.stop() # patch.dict automatically restores sys.modules