Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit0b1b52b

Browse files
authored
fix flaky test test_88_random_error (#1171)
1 parentba58ebc commit0b1b52b

File tree

1 file changed

+5
-14
lines changed

1 file changed

+5
-14
lines changed

‎tests/issues/test_88_random_error.py

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,7 @@ async def test_notification_validation_error(tmp_path: Path):
2828

2929
server=Server(name="test")
3030
request_count=0
31-
slow_request_started=anyio.Event()
32-
slow_request_complete=anyio.Event()
31+
slow_request_lock=anyio.Event()
3332

3433
@server.list_tools()
3534
asyncdeflist_tools()->list[types.Tool]:
@@ -52,16 +51,9 @@ async def slow_tool(name: str, arg) -> Sequence[ContentBlock]:
5251
request_count+=1
5352

5453
ifname=="slow":
55-
# Signal that slow request has started
56-
slow_request_started.set()
57-
# Long enough to ensure timeout
58-
awaitanyio.sleep(0.2)
59-
# Signal completion
60-
slow_request_complete.set()
54+
awaitslow_request_lock.wait()# it should timeout here
6155
return [TextContent(type="text",text=f"slow{request_count}")]
6256
elifname=="fast":
63-
# Fast enough to complete before timeout
64-
awaitanyio.sleep(0.01)
6557
return [TextContent(type="text",text=f"fast{request_count}")]
6658
return [TextContent(type="text",text=f"unknown{request_count}")]
6759

@@ -90,16 +82,15 @@ async def client(read_stream, write_stream, scope):
9082
# First call should work (fast operation)
9183
result=awaitsession.call_tool("fast")
9284
assertresult.content== [TextContent(type="text",text="fast 1")]
93-
assertnotslow_request_complete.is_set()
85+
assertnotslow_request_lock.is_set()
9486

9587
# Second call should timeout (slow operation)
9688
withpytest.raises(McpError)asexc_info:
9789
awaitsession.call_tool("slow")
9890
assert"Timed out while waiting"instr(exc_info.value)
9991

100-
# Wait for slow request to complete in the background
101-
withanyio.fail_after(1):# Timeout after 1 second
102-
awaitslow_request_complete.wait()
92+
# release the slow request not to have hanging process
93+
slow_request_lock.set()
10394

10495
# Third call should work (fast operation),
10596
# proving server is still responsive

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp