22
33import fastapi
44import litestar
5- from fastapi .testclient import TestClient
5+ from fastapi .testclient import TestClient as FastAPITestClient
66from litestar import openapi , status_codes
77from litestar .openapi import spec as litestar_openapi
88from litestar .openapi .plugins import ScalarRenderPlugin
99from litestar .static_files import StaticFilesConfig
10- from litestar .testing import AsyncTestClient
10+ from litestar .testing import TestClient as LitestarTestClient
1111
1212from microbootstrap .bootstrappers .fastapi import FastApiSwaggerInstrument
1313from microbootstrap .bootstrappers .litestar import LitestarSwaggerInstrument
@@ -97,7 +97,7 @@ def test_litestar_swagger_bootstrap_offline_docs(minimal_swagger_config: Swagger
9797 assert isinstance (bootstrap_result ["static_files_config" ][0 ], StaticFilesConfig )
9898
9999
100- async def test_litestar_swagger_bootstrap_working_online_docs (
100+ def test_litestar_swagger_bootstrap_working_online_docs (
101101 minimal_swagger_config : SwaggerConfig ,
102102) -> None :
103103 minimal_swagger_config .swagger_path = "/my-docs-path"
@@ -108,12 +108,12 @@ async def test_litestar_swagger_bootstrap_working_online_docs(
108108 ** swagger_instrument .bootstrap_before (),
109109 )
110110
111- async with AsyncTestClient (app = litestar_application ) as async_client :
112- response : typing .Final = await async_client .get (minimal_swagger_config .swagger_path )
111+ with LitestarTestClient (app = litestar_application ) as test_client :
112+ response : typing .Final = test_client .get (minimal_swagger_config .swagger_path )
113113 assert response .status_code == status_codes .HTTP_200_OK
114114
115115
116- async def test_litestar_swagger_bootstrap_working_offline_docs (
116+ def test_litestar_swagger_bootstrap_working_offline_docs (
117117 minimal_swagger_config : SwaggerConfig ,
118118) -> None :
119119 minimal_swagger_config .service_static_path = "/my-static-path"
@@ -125,10 +125,10 @@ async def test_litestar_swagger_bootstrap_working_offline_docs(
125125 ** swagger_instrument .bootstrap_before (),
126126 )
127127
128- async with AsyncTestClient (app = litestar_application ) as async_client :
129- response = await async_client .get (minimal_swagger_config .swagger_path )
128+ with LitestarTestClient (app = litestar_application ) as test_client :
129+ response = test_client .get (minimal_swagger_config .swagger_path )
130130 assert response .status_code == status_codes .HTTP_200_OK
131- response = await async_client .get (f"{ minimal_swagger_config .service_static_path } /swagger-ui.css" )
131+ response = test_client .get (f"{ minimal_swagger_config .service_static_path } /swagger-ui.css" )
132132 assert response .status_code == status_codes .HTTP_200_OK
133133
134134
@@ -152,7 +152,7 @@ def test_fastapi_swagger_bootstrap_working_online_docs(
152152 ** swagger_instrument .bootstrap_before (),
153153 )
154154
155- response : typing .Final = TestClient (app = fastapi_application ).get (minimal_swagger_config .swagger_path )
155+ response : typing .Final = FastAPITestClient (app = fastapi_application ).get (minimal_swagger_config .swagger_path )
156156 assert response .status_code == status_codes .HTTP_200_OK
157157
158158
@@ -167,7 +167,7 @@ def test_fastapi_swagger_bootstrap_working_offline_docs(
167167 )
168168 swagger_instrument .bootstrap_after (fastapi_application )
169169
170- with TestClient (app = fastapi_application ) as test_client :
170+ with FastAPITestClient (app = fastapi_application ) as test_client :
171171 response = test_client .get (minimal_swagger_config .swagger_path )
172172 assert response .status_code == status_codes .HTTP_200_OK
173173 response = test_client .get (f"{ minimal_swagger_config .service_static_path } /swagger-ui.css" )
0 commit comments