Fix: mock test tests

This commit is contained in:
Sameer Kankute 2026-01-15 22:02:51 +05:30
parent 83e33944ef
commit 8c454eb74f

View file

@ -8,7 +8,7 @@ and following LiteLLM testing patterns and best practices.
# Standard library imports
import os
import sys
from typing import Dict
from typing import Dict, Any
from unittest.mock import Mock, patch
# Add parent directory to path for imports
@ -43,35 +43,6 @@ from litellm.proxy.guardrails.init_guardrails import init_guardrails_v2
# ============================================================================
@pytest.fixture(scope="function", autouse=True)
def setup_and_teardown():
"""
Standard LiteLLM fixture that reloads litellm before every function
to speed up testing by removing callbacks being chained.
"""
import asyncio
import sys
# Only reload if litellm is already in sys.modules
if "litellm" in sys.modules:
import importlib
importlib.reload(litellm)
# Set up async loop
loop = asyncio.get_event_loop_policy().new_event_loop()
asyncio.set_event_loop(loop)
# Set up litellm state
litellm.set_verbose = True
litellm.guardrail_name_config_map = {}
yield
# Teardown
loop.close()
asyncio.set_event_loop(None)
@pytest.fixture
def env_setup(monkeypatch):
"""Fixture to set up environment variables for testing."""