Your lightweight open-source personal agent.
Python agent-frameworkai-agentai-agentschatbotchatopsdiscord-botllm-agentsllmslocal-llmmcpmodel-context-protocolmulti-agentopenai-compatibleopenclawpersonal-ai-assistantpythonself-hostedtelegram-bot-ai-assistantwebuiworkflow-automation
refactor(api): reduce compatibility and test noise
Xubin Ren5e99b81c6e55
diff --git a/tests/test_openai_api.py b/tests/test_openai_api.pyindex d935729a8..3d29d4767 100644--- a/tests/test_openai_api.py+++ b/tests/test_openai_api.py@@ -7,6 +7,7 @@ import jsonfrom unittest.mock import AsyncMock, MagicMockimport pytest+import pytest_asynciofrom nanobot.api.server import (API_CHAT_ID,@@ -18,7 +19,7 @@ from nanobot.api.server import ()try:- import aiohttp # noqa: F401+ from aiohttp.test_utils import TestClient, TestServerHAS_AIOHTTP = Trueexcept ImportError:@@ -45,6 +46,23 @@ def app(mock_agent):return create_app(mock_agent, model_name="test-model", request_timeout=10.0)+@pytest_asyncio.fixture+async def aiohttp_client():+ clients: list[TestClient] = []++ async def _make_client(app):+ client = TestClient(TestServer(app))+ await client.start_server()+ clients.append(client)+ return client++ try:+ yield _make_client+ finally:+ for client in clients:+ await client.close()++def test_error_json() -> None:resp = _error_json(400, "bad request")assert resp.status == 400