From 409b402553d2d7e55eecd5b88d8bdeef4a1f33c7 Mon Sep 17 00:00:00 2001 From: mateo-berri <277851410+mateo-berri@users.noreply.github.com> Date: Sun, 6 Sep 2026 00:10:48 -0700 Subject: [PATCH] test(guardrails): pin the discovery cache by behavior instead of object identity --- .../llms/test_guardrail_translation_discovery.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/tests/test_litellm/llms/test_guardrail_translation_discovery.py b/tests/test_litellm/llms/test_guardrail_translation_discovery.py index 1879b15f5fd..cf2fd7e293d 100644 --- a/tests/test_litellm/llms/test_guardrail_translation_discovery.py +++ b/tests/test_litellm/llms/test_guardrail_translation_discovery.py @@ -102,11 +102,16 @@ def test_the_next_lookup_retries_a_package_that_failed_to_import(): assert not llms_package.guardrail_translation_discovery.unavailable -def test_a_complete_discovery_is_cached(): - first = llms_package.load_guardrail_translation_mappings() - second = llms_package.load_guardrail_translation_mappings() +def test_a_complete_discovery_is_not_scanned_again(): + healthy = llms_package.load_guardrail_translation_mappings() - assert first is second + assert CallTypes.acompletion in healthy + + with unimportable(OPENAI_CHAT_TRANSLATION_MODULE): + after_the_package_breaks = llms_package.load_guardrail_translation_mappings() + + assert CallTypes.acompletion in after_the_package_breaks + assert not llms_package.guardrail_translation_discovery.unavailable def test_a_package_that_keeps_failing_is_reported_once_and_its_recovery_announced(caplog):