我正在尝试为我的 fastapi 应用程序编写一些测试
\n\n\n我正在使用
\nprisma-client-py数据库。我不知道这是否会改变什么
一切都按预期工作,除了第一个和最后一个之外,它们都因相同的错误而失败:
\nRuntimeError: <asyncio.locks.Event object at 0x7f5696832950 [unset]> is bound to a different event loop\nRun Code Online (Sandbox Code Playgroud)\n这是我的conftest.py
import os\nimport asyncio\nimport pytest\nfrom typing import Any, AsyncGenerator, Generator, Iterator\n\nfrom fastapi import FastAPI\nfrom fastapi.testclient import TestClient\nfrom prisma import Prisma, register\n\n\nfrom server.database.base import *\nfrom server.config.exceptions import configure_exception_handlers\nfrom server.config.settings import settings\nfrom server.apis import apis\n\n\ndef start_application() -> FastAPI:\n """\n Return a FastAPI app\n """\n _app = FastAPI(\n title=str(settings.TITLE),\n description=str(settings.DESCRIPTION),\n version=str(settings.VERSION),\n )\n configure_exception_handlers(_app)\n _app.include_router(apis)\n return …Run Code Online (Sandbox Code Playgroud)