21
21
import pytest
22
22
import uvicorn
23
23
from asgi_lifespan import LifespanManager
24
+ from typing_extensions import ParamSpec
25
+
24
26
from fastapi_proxy_lib .fastapi .app import (
25
27
forward_http_app ,
26
28
reverse_http_app ,
27
29
reverse_ws_app ,
28
30
)
29
- from typing_extensions import ParamSpec
30
31
31
32
from .app .echo_http_app import get_app as get_http_test_app
32
33
from .app .echo_ws_app import get_app as get_ws_test_app
@@ -68,13 +69,13 @@ def __call__( # noqa: D102
68
69
69
70
70
71
# https://anyio.readthedocs.io/en/stable/testing.html#specifying-the-backends-to-run-on
71
- @pytest .fixture ()
72
+ @pytest .fixture
72
73
def anyio_backend () -> Literal ["asyncio" ]:
73
74
"""Specify the async backend for `pytest.mark.anyio`."""
74
75
return "asyncio"
75
76
76
77
77
- @pytest .fixture ()
78
+ @pytest .fixture
78
79
async def lifespan_manager () -> AsyncIterator [LifespanManagerFixture ]:
79
80
"""Fixture for asgi lifespan manager.
80
81
@@ -103,7 +104,7 @@ async def _lifespan_manager(app: ASGIApp) -> ASGIApp:
103
104
# 所以这里明确要求每个fixture的作用域都是"function",不要共享 TestAppDataclass
104
105
105
106
106
- @pytest .fixture ()
107
+ @pytest .fixture
107
108
async def echo_http_test_model (
108
109
lifespan_manager : LifespanManagerFixture ,
109
110
) -> LifeAppDataclass4Test :
@@ -119,7 +120,7 @@ def LifeAppDataclass4Test.request(): Get the latest original http request from t
119
120
return LifeAppDataclass4Test (app = life_app , request_dict = app_dataclass .request_dict )
120
121
121
122
122
- @pytest .fixture ()
123
+ @pytest .fixture
123
124
async def echo_ws_test_model (
124
125
lifespan_manager : LifespanManagerFixture ,
125
126
) -> LifeAppDataclass4Test :
@@ -157,7 +158,7 @@ async def wappered_app_fct(*args: _P.args, **kwargs: _P.kwargs) -> ASGIApp:
157
158
return wappered_app_fct
158
159
159
160
160
- @pytest .fixture ()
161
+ @pytest .fixture
161
162
def forward_http_app_fct (
162
163
lifespan_manager : LifespanManagerFixture ,
163
164
): # -> AppFactoryFixture
@@ -168,7 +169,7 @@ def forward_http_app_fct(
168
169
return _app_fct_life_wapper (forward_http_app , lifespan_manager )
169
170
170
171
171
- @pytest .fixture ()
172
+ @pytest .fixture
172
173
def reverse_http_app_fct (
173
174
lifespan_manager : LifespanManagerFixture ,
174
175
): # -> AppFactoryFixture
@@ -179,7 +180,7 @@ def reverse_http_app_fct(
179
180
return _app_fct_life_wapper (reverse_http_app , lifespan_manager )
180
181
181
182
182
- @pytest .fixture ()
183
+ @pytest .fixture
183
184
def reverse_ws_app_fct (
184
185
lifespan_manager : LifespanManagerFixture ,
185
186
): # -> AppFactoryFixture
@@ -190,7 +191,7 @@ def reverse_ws_app_fct(
190
191
return _app_fct_life_wapper (reverse_ws_app , lifespan_manager )
191
192
192
193
193
- @pytest .fixture ()
194
+ @pytest .fixture
194
195
async def uvicorn_server_fixture () -> AsyncIterator [UvicornServerFixture ]:
195
196
"""Fixture for UvicornServer.
196
197
0 commit comments