diff --git a/tests/llm_responses_api_testing/conftest.py b/tests/llm_responses_api_testing/conftest.py index b3561d8a626..197dce9a020 100644 --- a/tests/llm_responses_api_testing/conftest.py +++ b/tests/llm_responses_api_testing/conftest.py @@ -11,6 +11,17 @@ sys.path.insert( ) # Adds the parent directory to the system path import litellm +import asyncio + +@pytest.fixture(scope="session") +def event_loop(): + try: + loop = asyncio.get_running_loop() + except RuntimeError: + loop = asyncio.new_event_loop() + yield loop + loop.close() + @pytest.fixture(scope="function", autouse=True) def setup_and_teardown(): diff --git a/tests/llm_translation/conftest.py b/tests/llm_translation/conftest.py index 38262eb590d..dcb6f5e6cfa 100644 --- a/tests/llm_translation/conftest.py +++ b/tests/llm_translation/conftest.py @@ -11,11 +11,14 @@ sys.path.insert( ) # Adds the parent directory to the system path import litellm +import asyncio @pytest.fixture(scope="session") def event_loop(): - """Create an instance of the default event loop for each test session.""" - loop = asyncio.get_event_loop_policy().new_event_loop() + try: + loop = asyncio.get_running_loop() + except RuntimeError: + loop = asyncio.new_event_loop() yield loop loop.close() diff --git a/tests/local_testing/conftest.py b/tests/local_testing/conftest.py index b3561d8a626..dbc6efa1b6c 100644 --- a/tests/local_testing/conftest.py +++ b/tests/local_testing/conftest.py @@ -11,6 +11,19 @@ sys.path.insert( ) # Adds the parent directory to the system path import litellm +import asyncio + +@pytest.fixture(scope="session") +def event_loop(): + try: + loop = asyncio.get_running_loop() + except RuntimeError: + loop = asyncio.new_event_loop() + yield loop + loop.close() + + + @pytest.fixture(scope="function", autouse=True) def setup_and_teardown(): diff --git a/tests/test_litellm/conftest.py b/tests/test_litellm/conftest.py index a88148f9d11..ac8a00d850c 100644 --- a/tests/test_litellm/conftest.py +++ b/tests/test_litellm/conftest.py @@ -9,9 +9,23 @@ import pytest sys.path.insert( 0, os.path.abspath("../..") ) # Adds the parent directory to the system path +import asyncio + import litellm +@pytest.fixture(scope="session") +def event_loop(): + try: + loop = asyncio.get_running_loop() + except RuntimeError: + loop = asyncio.new_event_loop() + yield loop + loop.close() + + + + @pytest.fixture(scope="function", autouse=True) def setup_and_teardown(): """