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]

refactor: remove dead code from Langfuse test cleanup

Julio Quinteros Pro4c53ccd90dc6
diff --git a/tests/test_litellm/integrations/test_langfuse.py b/tests/test_litellm/integrations/test_langfuse.py
index 20e551479c9..15f252a4afc 100644
--- a/tests/test_litellm/integrations/test_langfuse.py
+++ b/tests/test_litellm/integrations/test_langfuse.py
@@ -77,19 +77,12 @@ class TestLangfuseUsageDetails(unittest.TestCase):
sys.modules["langfuse"].Langfuse = self.mock_langfuse_class
# Create a fresh logger instance for each test
- # Force a clean state by clearing any class-level cached state
- if hasattr(LangFuseLogger, '_langfuse_clients'):
- LangFuseLogger._langfuse_clients = {}
-
self.logger = LangFuseLogger()
# Explicitly set the Langfuse client to our mock
self.logger.Langfuse = self.mock_langfuse_client
# Ensure langfuse_sdk_version is set correctly for _supports_* methods
self.logger.langfuse_sdk_version = "3.0.0"
- # Reset any cached client instances
- if hasattr(self.logger, '_langfuse_client_cache'):
- self.logger._langfuse_client_cache = None
# Add the log_event_on_langfuse method to the instance
def log_event_on_langfuse(
@@ -132,11 +125,9 @@ class TestLangfuseUsageDetails(unittest.TestCase):
def tearDown(self):
# Clean up logger instance to prevent state leakage
if hasattr(self, 'logger'):
- # Reset logger's Langfuse client
+ # Reset logger's Langfuse client to break any references
self.logger.Langfuse = None
- # Clear any cached state
- if hasattr(self.logger, '_langfuse_client_cache'):
- self.logger._langfuse_client_cache = None
+ # Delete logger instance to ensure complete cleanup
del self.logger
self.env_patcher.stop()