88import sqlalchemy
99from asgi_lifespan import LifespanManager
1010from fastapi import FastAPI
11- from httpx import AsyncClient
11+ from httpx import ASGITransport , AsyncClient
1212from ormar import post_save
1313from pydantic import ConfigDict , computed_field
1414
@@ -123,7 +123,8 @@ async def create_user7(user: RandomModel):
123123
124124@pytest .mark .asyncio
125125async def test_excluding_fields_in_endpoints ():
126- client = AsyncClient (app = app , base_url = "http://testserver" )
126+ transport = ASGITransport (app = app )
127+ client = AsyncClient (transport = transport , base_url = "http://testserver" )
127128 async with client as client , LifespanManager (app ):
128129 user = {
129130 "email" : "test@domain.com" ,
@@ -197,7 +198,8 @@ async def test_excluding_fields_in_endpoints():
197198
198199@pytest .mark .asyncio
199200async def test_adding_fields_in_endpoints ():
200- client = AsyncClient (app = app , base_url = "http://testserver" )
201+ transport = ASGITransport (app = app )
202+ client = AsyncClient (transport = transport , base_url = "http://testserver" )
201203 async with client as client , LifespanManager (app ):
202204 user3 = {"last_name" : "Test" , "full_name" : "deleted" }
203205 response = await client .post ("/random/" , json = user3 )
@@ -226,7 +228,8 @@ async def test_adding_fields_in_endpoints():
226228
227229@pytest .mark .asyncio
228230async def test_adding_fields_in_endpoints2 ():
229- client = AsyncClient (app = app , base_url = "http://testserver" )
231+ transport = ASGITransport (app = app )
232+ client = AsyncClient (transport = transport , base_url = "http://testserver" )
230233 async with client as client , LifespanManager (app ):
231234 user3 = {"last_name" : "Test" }
232235 response = await client .post ("/random2/" , json = user3 )
@@ -249,7 +252,8 @@ async def test_excluding_property_field_in_endpoints2():
249252 async def after_save (sender , instance , ** kwargs ):
250253 dummy_registry [instance .pk ] = instance .model_dump ()
251254
252- client = AsyncClient (app = app , base_url = "http://testserver" )
255+ transport = ASGITransport (app = app )
256+ client = AsyncClient (transport = transport , base_url = "http://testserver" )
253257 async with client as client , LifespanManager (app ):
254258 user3 = {"last_name" : "Test" }
255259 response = await client .post ("/random3/" , json = user3 )
0 commit comments