Merge pull request #21254 from BerriAI/fix/langfuse-test-counter-cleanup

fix(test): restore Langfuse client counter in test cleanup
This commit is contained in:
jquinter 2026-02-15 14:18:22 -03:00 committed by GitHub
commit 0b66bbd904
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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