diff --git a/docs_src/custom_response/tutorial009c.py b/docs_src/custom_response/tutorial009c.py index 337f0cd20..6ac4e2ab7 100644 --- a/docs_src/custom_response/tutorial009c.py +++ b/docs_src/custom_response/tutorial009c.py @@ -10,6 +10,7 @@ class CustomORJSONResponse(Response): def render(self, content: Any) -> bytes: import orjson + assert orjson is not None, "orjson must be installed" return orjson.dumps(content, option=orjson.OPT_INDENT_2) diff --git a/tests/test_default_response_class.py b/tests/test_default_response_class.py index bd37e13e0..821a71373 100644 --- a/tests/test_default_response_class.py +++ b/tests/test_default_response_class.py @@ -1,7 +1,6 @@ from typing import Any import pytest - from fastapi import APIRouter, FastAPI from fastapi.responses import HTMLResponse, JSONResponse, PlainTextResponse from fastapi.testclient import TestClient @@ -12,6 +11,7 @@ class ORJSONResponse(JSONResponse): def render(self, content: Any) -> bytes: import orjson + return orjson.dumps(content)