Skip to content

Commit cfa36f7

Browse files
committed
test(test_1363): remove unused code to improve coverage
1 parent 2f9ac44 commit cfa36f7

File tree

1 file changed

+6
-14
lines changed

1 file changed

+6
-14
lines changed

tests/issues/test_1363_race_condition_streamable_http.py

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@
2828

2929
from mcp.server import Server
3030
from mcp.server.streamable_http_manager import StreamableHTTPSessionManager
31-
from mcp.types import Tool
3231

3332
SERVER_NAME = "test_race_condition_server"
3433

@@ -37,9 +36,6 @@ class RaceConditionTestServer(Server):
3736
def __init__(self):
3837
super().__init__(SERVER_NAME)
3938

40-
async def on_list_tools(self) -> list[Tool]:
41-
return []
42-
4339

4440
def create_app(json_response: bool = False) -> Starlette:
4541
"""Create a Starlette application for testing."""
@@ -78,15 +74,11 @@ def run(self) -> None:
7874

7975
# Create a new event loop for this thread
8076
async def run_lifespan():
81-
# Use the lifespan context if it exists
77+
# Use the lifespan context (always present in our tests)
8278
lifespan_context = getattr(self.app.router, "lifespan_context", None)
83-
if lifespan_context is not None:
84-
async with lifespan_context(self.app):
85-
# Wait until stop is requested
86-
while not self._stop_event.is_set():
87-
await anyio.sleep(0.1)
88-
else:
89-
# If no lifespan, just wait
79+
assert lifespan_context is not None # Tests always create apps with lifespan
80+
async with lifespan_context(self.app):
81+
# Wait until stop is requested
9082
while not self._stop_event.is_set():
9183
await anyio.sleep(0.1)
9284

@@ -108,7 +100,7 @@ def check_logs_for_race_condition_errors(caplog: pytest.LogCaptureFixture, test_
108100
# Check for specific race condition errors in logs
109101
errors_found: list[str] = []
110102

111-
for record in caplog.records:
103+
for record in caplog.records: # pragma: no cover
112104
message = record.getMessage()
113105
if "ClosedResourceError" in message:
114106
errors_found.append("ClosedResourceError")
@@ -118,7 +110,7 @@ def check_logs_for_race_condition_errors(caplog: pytest.LogCaptureFixture, test_
118110
errors_found.append("anyio.ClosedResourceError")
119111

120112
# Assert no race condition errors occurred
121-
if errors_found:
113+
if errors_found: # pragma: no cover
122114
error_msg = f"Test '{test_name}' found race condition errors in logs: {', '.join(set(errors_found))}\n"
123115
error_msg += "Log records:\n"
124116
for record in caplog.records:

0 commit comments

Comments
 (0)