Browse Source

Fix test setup and ensure stream_item_type is preserved after include_router

pull/15435/head
Prashanth1602 3 months ago
parent
commit
cbde193280
  1. 6
      tests/test_sse.py

6
tests/test_sse.py

@ -1,6 +1,6 @@
import asyncio import asyncio
import time import time
from collections.abc import AsyncIterable, Iterable from collections.abc import AsyncIterable, Iterable, AsyncIterator
import fastapi.routing import fastapi.routing
import pytest import pytest
@ -269,12 +269,12 @@ def test_include_router_copies_stream_item_type():
sub_router = APIRouter() sub_router = APIRouter()
@sub_router.get("/stream_item_type", response_class=EventSourceResponse) @sub_router.get("/stream_item_type", response_class=EventSourceResponse)
async def stream_item_type_route() -> AsyncIterable[Item]: async def stream_item_type_route() -> AsyncIterator[Item]:
yield items[0] yield items[0]
assert getattr(sub_router.routes[-1], "stream_item_type", None) == Item assert getattr(sub_router.routes[-1], "stream_item_type", None) == Item
main_app = FastAPI() main_app = FastAPI()
main_app.include_router(sub_router) main_app.include_router(sub_router)
route = next(r for r in main_app.routes if r.path == "/stream_item_type") route = next(r for r in main_app.routes if r.path == "/stream_item_type")

Loading…
Cancel
Save