File tree Expand file tree Collapse file tree 1 file changed +13
-6
lines changed
Expand file tree Collapse file tree 1 file changed +13
-6
lines changed Original file line number Diff line number Diff line change 66import logging
77import os
88import warnings
9- from typing import TYPE_CHECKING , cast
9+ from typing import TYPE_CHECKING , Any , cast
1010
1111import pytest
1212from curl_cffi import CurlHttpVersion
@@ -205,9 +205,16 @@ def redirect_server_url(redirect_http_server: TestServer) -> URL:
205205 pytest .param ('curl' , id = 'curl' ),
206206 ]
207207)
208- async def http_client (request : pytest .FixtureRequest ) -> HttpClient :
208+ async def http_client (request : pytest .FixtureRequest ) -> AsyncGenerator [HttpClient , None ]:
209+ class_client : type [HttpClient ]
209210 if request .param == 'curl' :
210- return CurlImpersonateHttpClient (http_version = CurlHttpVersion .V1_1 )
211- if request .param == 'impit' :
212- return ImpitHttpClient (http3 = False )
213- return HttpxHttpClient (http2 = False )
211+ class_client = CurlImpersonateHttpClient
212+ kwargs : dict [str , Any ] = {'http_version' : CurlHttpVersion .V1_1 }
213+ elif request .param == 'impit' :
214+ class_client = ImpitHttpClient
215+ kwargs = {'http3' : False }
216+ else :
217+ class_client = HttpxHttpClient
218+ kwargs = {'http2' : True }
219+ async with class_client (** kwargs ) as client :
220+ yield client
You can’t perform that action at this time.
0 commit comments