From 5fe1dd3ec87ca54575ed83fc15fefe5e5d4d4f97 Mon Sep 17 00:00:00 2001 From: Julio Quinteros Pro Date: Wed, 18 Feb 2026 19:09:35 -0300 Subject: [PATCH] fix(tests): restore initialized_langfuse_clients counter after test Save and restore litellm.initialized_langfuse_clients around test_max_langfuse_clients_limit to prevent ordering-dependent failures in other tests that rely on the counter's value. Co-Authored-By: Claude Sonnet 4.6 --- tests/test_litellm/integrations/test_langfuse.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tests/test_litellm/integrations/test_langfuse.py b/tests/test_litellm/integrations/test_langfuse.py index 77ff5dbb97..10d3323a25 100644 --- a/tests/test_litellm/integrations/test_langfuse.py +++ b/tests/test_litellm/integrations/test_langfuse.py @@ -478,6 +478,7 @@ def test_max_langfuse_clients_limit(): mock_langfuse = MagicMock() mock_langfuse.version.__version__ = "3.0.0" # Set max clients to 2 for testing + original_initialized_langfuse_clients = litellm.initialized_langfuse_clients with patch.dict("sys.modules", {"langfuse": mock_langfuse}), patch.object( langfuse_module, "MAX_LANGFUSE_INITIALIZED_CLIENTS", 2 ): @@ -513,3 +514,5 @@ def test_max_langfuse_clients_limit(): # Counter should still be 2 (third client failed to initialize) assert litellm.initialized_langfuse_clients == 2 + + litellm.initialized_langfuse_clients = original_initialized_langfuse_clients