diff --git a/tests/test_application.py b/tests/test_application.py index fbbda578a..a7d50ea72 100644 --- a/tests/test_application.py +++ b/tests/test_application.py @@ -1,6 +1,5 @@ import pytest from dirty_equals import IsDict -from fastapi import FastAPI from fastapi.testclient import TestClient from .main import app @@ -53,18 +52,6 @@ def test_enum_status_code_response(): assert response.json() == "foo bar" -def test_allow_async_openapi(): - async def async_openapi(): - return {"foo": "bar"} - - mod_app = FastAPI() # use fresh instance to not affect other tests - mod_app.openapi = async_openapi - mod_client = TestClient(mod_app) - response = mod_client.get("/openapi.json") - assert response.status_code == 200, response.text - assert response.json() == {"foo": "bar"} - - def test_openapi_schema(): response = client.get("/openapi.json") assert response.status_code == 200, response.text diff --git a/tests/test_openapi_async.py b/tests/test_openapi_async.py new file mode 100644 index 000000000..352f889a9 --- /dev/null +++ b/tests/test_openapi_async.py @@ -0,0 +1,14 @@ +from fastapi import FastAPI +from fastapi.testclient import TestClient + + +def test_allow_async_openapi(): + async def async_openapi(): + return {"foo": "bar"} + + mod_app = FastAPI() # use fresh instance to not affect other tests + mod_app.openapi = async_openapi + mod_client = TestClient(mod_app) + response = mod_client.get("/openapi.json") + assert response.status_code == 200, response.text + assert response.json() == {"foo": "bar"}