Skip to content

Commit 66f82b9

Browse files
committed
fix(django5): set cookies on AsyncClient instance to avoid deprecation warning
Move cookie parameter from per-request to AsyncClient constructor. This aligns with httpx's preferred API and eliminates the deprecation warning.
1 parent 9c0f1b2 commit 66f82b9

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

test_project_django5/test_middleware.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -101,11 +101,12 @@ def create_session():
101101
# Make request with session cookie - this should trigger the bug in v6.7.11
102102
# Disable exception capture to see the SynchronousOnlyOperation clearly
103103
with override_settings(POSTHOG_MW_CAPTURE_EXCEPTIONS=False):
104-
async with AsyncClient(transport=ASGITransport(app=asgi_app), base_url="http://testserver") as ac:
105-
response = await ac.get(
106-
"/test/async-user",
107-
cookies={"sessionid": session_cookie.value}
108-
)
104+
async with AsyncClient(
105+
transport=ASGITransport(app=asgi_app),
106+
base_url="http://testserver",
107+
cookies={"sessionid": session_cookie.value}
108+
) as ac:
109+
response = await ac.get("/test/async-user")
109110

110111
assert response.status_code == 200
111112
data = response.json()

0 commit comments

Comments
 (0)