From 1c3f66c2f5a3c822ee06c9404776cb98fead4c8f Mon Sep 17 00:00:00 2001 From: geo-martino Date: Sun, 17 Nov 2024 22:49:01 -0500 Subject: [PATCH] fix default loop scope --- pyproject.toml | 2 +- tests/conftest.py | 11 +++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 8e7c8eb9..4ceedd60 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -113,4 +113,4 @@ markers = [ "manual: marks tests to be run only when manually directed to by the developer", ] asyncio_mode = "auto" -asyncio_default_fixture_loop_scope="function" +asyncio_default_fixture_loop_scope = "session" diff --git a/tests/conftest.py b/tests/conftest.py index 7fda30c9..2b60c624 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -1,3 +1,4 @@ +import asyncio import copy import logging.config import shutil @@ -23,6 +24,16 @@ from tests.utils import idfn, path_resources +@pytest.fixture(scope="session") +def event_loop(): + try: + loop = asyncio.get_running_loop() + except RuntimeError: + loop = asyncio.new_event_loop() + yield loop + loop.close() + + # noinspection PyUnusedLocal @pytest.hookimpl def pytest_configure(config: pytest.Config):