Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Fix FastAPI lifespan integration in pytest #393

Open
@Zaczero

Description

@Zaczero

Describe the bug

Currently because of broken lifespan integration in pytest, you need to duplicate code like:

@pytest_asyncio.fixture(scope="session")asyncdefapp_client(app):awaitcreate_index_templates()awaitcreate_collection_index()asyncwithAsyncClient(transport=ASGITransport(app=app),base_url="http://test-server"    )asc:yieldc

despite having:

@asynccontextmanagerasyncdeflifespan(app:FastAPI):"""Lifespan handler for FastAPI app. Initializes index templates and collections at startup."""awaitcreate_index_templates()awaitcreate_collection_index()yield

It'sfairly simple to fix, feel free to use this code:

This should make the tests more consistent with the actual deployment.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp