AutoGPT is the vision of accessible AI for everyone, to use and to build on. Our mission is to provide the tools, so that you can focus on what matters.
fix(backend): align pytest async loop scope (#14267)
Nicholas Tindlebc51a006c189
diff --git a/autogpt_platform/backend/backend/copilot/graphiti/conftest.py b/autogpt_platform/backend/backend/copilot/graphiti/conftest.pyindex ba04462062..4484ba66d5 100644--- a/autogpt_platform/backend/backend/copilot/graphiti/conftest.py+++ b/autogpt_platform/backend/backend/copilot/graphiti/conftest.py@@ -34,6 +34,7 @@ import socketimport uuidfrom collections.abc import Iterablefrom datetime import datetime, timezone+from pathlib import Pathfrom typing import AsyncIteratorimport pytest@@ -51,6 +52,19 @@ from .config import graphiti_configfrom .falkordb_driver import AutoGPTFalkorDriver+def pytest_collection_modifyitems(items: list[pytest.Item]) -> None:+ graphiti_dir = Path(__file__).parent+ for item in items:+ if not item.path.is_relative_to(graphiti_dir):+ continue+ if not pytest_asyncio.is_async_test(item):+ continue+ asyncio_marker = item.get_closest_marker("asyncio")+ if asyncio_marker and "loop_scope" in asyncio_marker.kwargs:+ continue+ item.add_marker(pytest.mark.asyncio(loop_scope="function"), append=False)++class ScriptedLLMClient(LLMClient):"""Real ``LLMClient`` whose responses are canned per response model.diff --git a/autogpt_platform/backend/pyproject.toml b/autogpt_platform/backend/pyproject.tomlindex 469a061782..f1b825a8df 100644--- a/autogpt_platform/backend/pyproject.toml+++ b/autogpt_platform/backend/pyproject.toml@@ -177,6 +177,7 @@ ignore_patterns = [][tool.pytest.ini_options]asyncio_mode = "auto"asyncio_default_fixture_loop_scope = "session"+asyncio_default_test_loop_scope = "session"# Disable syrupy plugin to avoid conflict with pytest-snapshot# Both provide --snapshot-update argument causing ArgumentErroraddopts = "-p no:syrupy"