Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ per-file-ignores = { "tests/**" = ["F401", "F841"] }
[tool.pytest.ini_options]
addopts = "-q --maxfail=1 --disable-warnings --cov=mcp_fuzzer --cov-report=term-missing --cov-report=xml"
testpaths = ["tests"]
asyncio_mode = "auto"

[tool.coverage.run]
branch = true
Expand Down
15 changes: 7 additions & 8 deletions tests/test_streamable_http.py
Original file line number Diff line number Diff line change
@@ -1,21 +1,20 @@
"""Async tests use pytest-asyncio."""

import asyncio
import types
from typing import Any, Dict, List, Optional

import pytest

# Skip this module if pytest-asyncio is not available to avoid failing runs
pytest.importorskip("pytest_asyncio")
from mcp_fuzzer.transport.streamable_http import (
StreamableHTTPTransport,
CONTENT_TYPE,
)
from mcp_fuzzer.config import DEFAULT_PROTOCOL_VERSION


# Force anyio to use asyncio backend for these tests (no trio dependency required)
@pytest.fixture
def anyio_backend():
return "asyncio"


class _DummyResponse:
def __init__(
self,
Expand Down Expand Up @@ -80,7 +79,7 @@ async def post(self, url: str, json: Dict[str, Any], headers: Dict[str, str]):
return self._responses.pop(0)


@pytest.mark.anyio("asyncio")
@pytest.mark.asyncio
async def test_streamable_http_json_initialize(monkeypatch):
# Arrange: first call returns JSON initialize with session header
init_result = {"protocolVersion": DEFAULT_PROTOCOL_VERSION, "ok": True}
Expand Down Expand Up @@ -122,7 +121,7 @@ async def test_streamable_http_json_initialize(monkeypatch):
assert last_headers.get("mcp-protocol-version") == DEFAULT_PROTOCOL_VERSION


@pytest.mark.anyio("asyncio")
@pytest.mark.asyncio
async def test_streamable_http_sse_response(monkeypatch):
# Arrange: SSE data with one JSON-RPC response containing result
sse_lines = [
Expand Down
1 change: 1 addition & 0 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ description = Run unit tests with coverage
deps =
pytest
pytest-cov
pytest-asyncio
commands =
pytest -vv --cov=mcp_fuzzer --cov-report=term-missing
basepython = python3