Skip to content

Commit 0582bf5

Browse files
committed
try fixing test
1 parent 91c09a4 commit 0582bf5

File tree

1 file changed

+16
-22
lines changed

1 file changed

+16
-22
lines changed

tests/shared/test_sse.py

Lines changed: 16 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -161,29 +161,23 @@ async def http_client(server, server_url) -> AsyncGenerator[httpx.AsyncClient, N
161161
@pytest.mark.anyio
162162
async def test_raw_sse_connection(http_client: httpx.AsyncClient) -> None:
163163
"""Test the SSE connection establishment simply with an HTTP client."""
164-
async with anyio.create_task_group():
165-
166-
async def connection_test() -> None:
167-
async with http_client.stream("GET", "/sse") as response:
168-
assert response.status_code == 200
169-
assert (
170-
response.headers["content-type"]
171-
== "text/event-stream; charset=utf-8"
172-
)
164+
with anyio.fail_after(3):
165+
async with http_client.stream("GET", "/sse") as response:
166+
assert response.status_code == 200
167+
assert (
168+
response.headers["content-type"]
169+
== "text/event-stream; charset=utf-8"
170+
)
173171

174-
line_number = 0
175-
async for line in response.aiter_lines():
176-
if line_number == 0:
177-
assert line == "event: endpoint"
178-
elif line_number == 1:
179-
assert line.startswith("data: /messages/?session_id=")
180-
else:
181-
return
182-
line_number += 1
183-
184-
# Add timeout to prevent test from hanging if it fails
185-
with anyio.fail_after(3):
186-
await connection_test()
172+
line_number = 0
173+
async for line in response.aiter_lines():
174+
if line_number == 0:
175+
assert line == "event: endpoint"
176+
elif line_number == 1:
177+
assert line.startswith("data: /messages/?session_id=")
178+
else:
179+
return
180+
line_number += 1
187181

188182

189183
@pytest.mark.anyio

0 commit comments

Comments
 (0)