Skip to content

Commit 3356ff2

Browse files
committed
fix: some assertions were still conditional
1 parent 735581c commit 3356ff2

1 file changed

Lines changed: 19 additions & 19 deletions

File tree

tests/integrations/fastmcp/test_fastmcp.py

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -474,14 +474,14 @@ def failing_tool(value: int) -> int:
474474
tool_spans = [s for s in tx["spans"] if s["op"] == OP.MCP_SERVER]
475475
assert len(tool_spans) == 1
476476

477-
# Error event may or may not be captured depending on MCP error handling
477+
# Check error event was captured
478478
error_events = [e for e in events if e.get("level") == "error"]
479-
if len(error_events) > 0:
480-
error_event = error_events[0]
481-
assert error_event["exception"]["values"][0]["type"] == "ValueError"
482-
assert error_event["exception"]["values"][0]["value"] == "Tool execution failed"
483-
# Verify span is marked with error
484-
assert tool_spans[0]["data"][SPANDATA.MCP_TOOL_RESULT_IS_ERROR] is True
479+
assert len(error_events) >= 1
480+
error_event = error_events[0]
481+
assert error_event["exception"]["values"][0]["type"] == "ValueError"
482+
assert error_event["exception"]["values"][0]["value"] == "Tool execution failed"
483+
# Verify span is marked with error
484+
assert tool_spans[0]["data"][SPANDATA.MCP_TOOL_RESULT_IS_ERROR] is True
485485

486486

487487
@pytest.mark.parametrize("FastMCP", fastmcp_implementations, ids=fastmcp_ids)
@@ -929,10 +929,10 @@ def sse_tool(value: str) -> dict:
929929

930930
# Find MCP spans
931931
mcp_spans = [s for s in tx["spans"] if s["op"] == OP.MCP_SERVER]
932-
if len(mcp_spans) > 0 and request_ctx is not None:
933-
span = mcp_spans[0]
934-
# Check that SSE transport is detected
935-
assert span["data"].get(SPANDATA.MCP_TRANSPORT) == "sse"
932+
assert len(mcp_spans) >= 1
933+
span = mcp_spans[0]
934+
# Check that SSE transport is detected
935+
assert span["data"].get(SPANDATA.MCP_TRANSPORT) == "sse"
936936

937937

938938
@pytest.mark.parametrize("FastMCP", fastmcp_implementations, ids=fastmcp_ids)
@@ -967,10 +967,10 @@ def http_tool(data: str) -> dict:
967967

968968
# Find MCP spans
969969
mcp_spans = [s for s in tx["spans"] if s["op"] == OP.MCP_SERVER]
970-
if len(mcp_spans) > 0 and request_ctx is not None:
971-
span = mcp_spans[0]
972-
# Check that HTTP transport is detected
973-
assert span["data"].get(SPANDATA.MCP_TRANSPORT) == "http"
970+
assert len(mcp_spans) >= 1
971+
span = mcp_spans[0]
972+
# Check that HTTP transport is detected
973+
assert span["data"].get(SPANDATA.MCP_TRANSPORT) == "http"
974974

975975

976976
@pytest.mark.parametrize("FastMCP", fastmcp_implementations, ids=fastmcp_ids)
@@ -1003,10 +1003,10 @@ def stdio_tool(n: int) -> dict:
10031003

10041004
# Find MCP spans
10051005
mcp_spans = [s for s in tx["spans"] if s["op"] == OP.MCP_SERVER]
1006-
if len(mcp_spans) > 0 and request_ctx is not None:
1007-
span = mcp_spans[0]
1008-
# Check that stdio transport is detected
1009-
assert span["data"].get(SPANDATA.MCP_TRANSPORT) == "stdio"
1006+
assert len(mcp_spans) >= 1
1007+
span = mcp_spans[0]
1008+
# Check that stdio transport is detected
1009+
assert span["data"].get(SPANDATA.MCP_TRANSPORT) == "stdio"
10101010

10111011

10121012
# =============================================================================

0 commit comments

Comments
 (0)