From a75414d733d6ddd75881c67c8a0609d06c16721d Mon Sep 17 00:00:00 2001 From: svlandeg Date: Tue, 4 Nov 2025 15:23:57 +0100 Subject: [PATCH] fix AsyncClient usage --- tests/test_depends_deadlock.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/tests/test_depends_deadlock.py b/tests/test_depends_deadlock.py index 268ae316e1..33068e2bc1 100644 --- a/tests/test_depends_deadlock.py +++ b/tests/test_depends_deadlock.py @@ -3,8 +3,8 @@ import threading import time from typing import Generator -import httpx from fastapi import Depends, FastAPI +from httpx import ASGITransport, AsyncClient from pydantic import BaseModel app = FastAPI() @@ -66,11 +66,13 @@ def get_deadlock(db: MyDB = Depends(get_db)): # able to free the resource without deadlocking, allowing each request to # be handled timely def test_depends_deadlock_patch(): - async def make_request(client: httpx.AsyncClient): + async def make_request(client: AsyncClient): await client.get("/deadlock") async def run_requests(): - async with httpx.AsyncClient(app=app, base_url="http://testserver") as aclient: + async with AsyncClient( + transport=ASGITransport(app=app), base_url="http://testserver" + ) as aclient: tasks = [make_request(aclient) for _ in range(100)] await asyncio.gather(*tasks)