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]

Fix pillar guardrails tests for parallel execution

Julio Quinteros Proab658d7d5005
diff --git a/tests/test_litellm/proxy/guardrails/test_pillar_guardrails.py b/tests/test_litellm/proxy/guardrails/test_pillar_guardrails.py
index 0607b0de981..392a047b5ce 100644
--- a/tests/test_litellm/proxy/guardrails/test_pillar_guardrails.py
+++ b/tests/test_litellm/proxy/guardrails/test_pillar_guardrails.py
@@ -51,9 +51,15 @@ def setup_and_teardown():
"""
import importlib
import asyncio
+ import sys
# Reload litellm to ensure clean state
- importlib.reload(litellm)
+ # During parallel test execution, another worker might have removed litellm from sys.modules
+ # so we need to ensure it's imported before reloading
+ if "litellm" not in sys.modules:
+ import litellm as _litellm
+ else:
+ importlib.reload(litellm)
# Set up async loop
loop = asyncio.get_event_loop_policy().new_event_loop()