From 1b3cec0f53854249bd63cb537bd41d20689eb576 Mon Sep 17 00:00:00 2001 From: xrwang8 Date: Wed, 16 Sep 2026 16:59:59 +0800 Subject: [PATCH] test(guardrails): make callback cleanup defensive Signed-off-by: xrwang8 --- .../guardrail_hooks/content_filter/test_content_filter.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/test_litellm/proxy/guardrails/guardrail_hooks/content_filter/test_content_filter.py b/tests/test_litellm/proxy/guardrails/guardrail_hooks/content_filter/test_content_filter.py index 4f513277f7e..d7579097bdb 100644 --- a/tests/test_litellm/proxy/guardrails/guardrail_hooks/content_filter/test_content_filter.py +++ b/tests/test_litellm/proxy/guardrails/guardrail_hooks/content_filter/test_content_filter.py @@ -115,7 +115,8 @@ class TestContentFilterGuardrail: assert result["texts"] == ["Call <> about <>"] finally: - litellm.callbacks.remove(guardrail) + if guardrail in litellm.callbacks: + litellm.callbacks.remove(guardrail) def test_check_patterns_ssn(self): """