2121import pytest
2222import uvicorn
2323from asgi_lifespan import LifespanManager
24+ from typing_extensions import ParamSpec
25+
2426from fastapi_proxy_lib .fastapi .app import (
2527 forward_http_app ,
2628 reverse_http_app ,
2729 reverse_ws_app ,
2830)
29- from typing_extensions import ParamSpec
3031
3132from .app .echo_http_app import get_app as get_http_test_app
3233from .app .echo_ws_app import get_app as get_ws_test_app
@@ -68,13 +69,13 @@ def __call__( # noqa: D102
6869
6970
7071# https://anyio.readthedocs.io/en/stable/testing.html#specifying-the-backends-to-run-on
71- @pytest .fixture ()
72+ @pytest .fixture
7273def anyio_backend () -> Literal ["asyncio" ]:
7374 """Specify the async backend for `pytest.mark.anyio`."""
7475 return "asyncio"
7576
7677
77- @pytest .fixture ()
78+ @pytest .fixture
7879async def lifespan_manager () -> AsyncIterator [LifespanManagerFixture ]:
7980 """Fixture for asgi lifespan manager.
8081
@@ -103,7 +104,7 @@ async def _lifespan_manager(app: ASGIApp) -> ASGIApp:
103104# 所以这里明确要求每个fixture的作用域都是"function",不要共享 TestAppDataclass
104105
105106
106- @pytest .fixture ()
107+ @pytest .fixture
107108async def echo_http_test_model (
108109 lifespan_manager : LifespanManagerFixture ,
109110) -> LifeAppDataclass4Test :
@@ -119,7 +120,7 @@ def LifeAppDataclass4Test.request(): Get the latest original http request from t
119120 return LifeAppDataclass4Test (app = life_app , request_dict = app_dataclass .request_dict )
120121
121122
122- @pytest .fixture ()
123+ @pytest .fixture
123124async def echo_ws_test_model (
124125 lifespan_manager : LifespanManagerFixture ,
125126) -> LifeAppDataclass4Test :
@@ -157,7 +158,7 @@ async def wappered_app_fct(*args: _P.args, **kwargs: _P.kwargs) -> ASGIApp:
157158 return wappered_app_fct
158159
159160
160- @pytest .fixture ()
161+ @pytest .fixture
161162def forward_http_app_fct (
162163 lifespan_manager : LifespanManagerFixture ,
163164): # -> AppFactoryFixture
@@ -168,7 +169,7 @@ def forward_http_app_fct(
168169 return _app_fct_life_wapper (forward_http_app , lifespan_manager )
169170
170171
171- @pytest .fixture ()
172+ @pytest .fixture
172173def reverse_http_app_fct (
173174 lifespan_manager : LifespanManagerFixture ,
174175): # -> AppFactoryFixture
@@ -179,7 +180,7 @@ def reverse_http_app_fct(
179180 return _app_fct_life_wapper (reverse_http_app , lifespan_manager )
180181
181182
182- @pytest .fixture ()
183+ @pytest .fixture
183184def reverse_ws_app_fct (
184185 lifespan_manager : LifespanManagerFixture ,
185186): # -> AppFactoryFixture
@@ -190,7 +191,7 @@ def reverse_ws_app_fct(
190191 return _app_fct_life_wapper (reverse_ws_app , lifespan_manager )
191192
192193
193- @pytest .fixture ()
194+ @pytest .fixture
194195async def uvicorn_server_fixture () -> AsyncIterator [UvicornServerFixture ]:
195196 """Fixture for UvicornServer.
196197
0 commit comments