mirror of
https://github.com/tiennm99/litellm.git
synced 2026-08-05 12:23:28 +00:00
Fix pillar guardrails tests for parallel execution
The setup_and_teardown fixture was failing with "ImportError: module litellm not in sys.modules" during parallel test execution. This occurs because another worker might have removed/modified litellm from sys.modules before this test tries to reload it. Fix: Check if litellm is in sys.modules before attempting reload.
This commit is contained in:
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user