From 6d744bdcd14807281ca5f5435ded937a5d0deb7f Mon Sep 17 00:00:00 2001 From: bkis Date: Tue, 24 Jun 2025 12:24:47 +0200 Subject: [PATCH] Move tests for async openapi func to dedicated test file --- tests/test_application.py | 13 ------------- tests/test_openapi_async.py | 14 ++++++++++++++ 2 files changed, 14 insertions(+), 13 deletions(-) create mode 100644 tests/test_openapi_async.py 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"}