pre-commit-ci-lite[bot]
5 months ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with
6 additions and
6 deletions
-
fastapi/responses.py
-
tests/test_sse_response.py
|
|
|
@ -1,6 +1,6 @@ |
|
|
|
import inspect |
|
|
|
from collections.abc import AsyncIterator, Iterator |
|
|
|
from typing import Any |
|
|
|
from collections.abc import AsyncIterator |
|
|
|
from collections.abc import Iterator |
|
|
|
|
|
|
|
from fastapi.exceptions import FastAPIDeprecationWarning |
|
|
|
from starlette.responses import FileResponse as FileResponse # noqa |
|
|
|
@ -11,7 +11,6 @@ from starlette.responses import RedirectResponse as RedirectResponse # noqa |
|
|
|
from starlette.responses import Response as Response # noqa |
|
|
|
from starlette.responses import StreamingResponse as StreamingResponse # noqa |
|
|
|
from typing_extensions import deprecated |
|
|
|
import inspect |
|
|
|
|
|
|
|
|
|
|
|
def _is_async(obj: Any) -> bool: |
|
|
|
@ -182,6 +181,7 @@ def format_sse( |
|
|
|
# SSE events are separated by double newlines |
|
|
|
return "\n".join(lines) + "\n\n" |
|
|
|
|
|
|
|
|
|
|
|
try: |
|
|
|
import ujson |
|
|
|
except ImportError: # pragma: nocover |
|
|
|
|
|
|
|
@ -1,5 +1,5 @@ |
|
|
|
"""Tests for Server-Sent Events (SSE) response classes.""" |
|
|
|
import pytest |
|
|
|
|
|
|
|
from fastapi import FastAPI |
|
|
|
from fastapi.responses import SSEResponse, format_sse |
|
|
|
from fastapi.testclient import TestClient |
|
|
|
@ -195,7 +195,7 @@ def test_sse_response_custom_headers(): |
|
|
|
|
|
|
|
def test_sse_export(): |
|
|
|
"""Test that SSEResponse is exported from fastapi.""" |
|
|
|
from fastapi import SSEResponse |
|
|
|
from fastapi import format_sse |
|
|
|
from fastapi import SSEResponse, format_sse |
|
|
|
|
|
|
|
assert SSEResponse is not None |
|
|
|
assert format_sse is not None |
|
|
|
|