class JSONResponse(Response):
media_type = "application/json"
+ def __init__(
+ self,
+ content: typing.Any,
+ status_code: int = 200,
+ headers: dict = None,
+ media_type: str = None,
+ background: BackgroundTask = None,
+ ) -> None:
+ super().__init__(content, status_code, headers, media_type, background)
+
def render(self, content: typing.Any) -> bytes:
return json.dumps(
content,
client = test_client_factory(app)
response = client.get("/")
assert response.json() is None
+ assert response.content == b"null"
def test_redirect_response(test_client_factory):
app = Response()
client: TestClient = test_client_factory(app)
response = client.get("/")
+ assert response.content == b""
assert response.headers["content-length"] == "0"
+ assert "content-type" not in response.headers
def test_empty_204_response(test_client_factory):