| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Sorry, something went wrong.
- Replace multiprocessing.Process with threading.Thread for context_aware_server fixture (same pattern as PR modelcontextprotocol#2341) - Remove 5 pragma: no cover markers from context-aware server code - Remove dead run_server() function and unused imports - Remaining 5 pragmas are on genuinely unreachable defensive code
Replace multiprocessing.Process with threading.Thread + uvicorn.Server for test server fixtures (basic_server, json_server, resumable_server) so coverage.py can track server-side code in the same process. Changes: - Add _start_server_thread() helper using uvicorn.Server in a daemon thread - Graceful shutdown via server.should_exit instead of proc.kill() - Remove 8 pragma: no cover from test fixtures (no longer needed) - Add 8 new tests covering previously-uncovered branches - Remove dead run_server() function and unused http_client fixture - Convert pragma: no cover to pragma: lax no cover in source files for non-deterministic coverage lines (thread timing dependent) - Add pragma: no branch for partial branch coverage on guard lines
- Add warnings.filterwarnings in _run_server thread to suppress asyncio.iscoroutinefunction deprecation (Python 3.14+) - Add ResourceWarning filter for unclosed sockets during teardown (Windows) - Add pytest filterwarnings for DeprecationWarning and PytestUnhandledThreadExceptionWarning in pyproject.toml
Add pragma annotations for 3 remaining uncovered paths: - pragma: no branch on mcp_session_id checks in _create_error_response and initialization handler (always True in stateful manager) - pragma: lax no cover on ClosedResourceError handler (non-deterministic) Add 5 integration tests for transport validation: - POST with invalid Content-Type (400) - POST/GET/DELETE with mismatched session ID (404) - PUT unsupported method (405) All 74 tests pass with 100% coverage and strict-no-cover clean.
|
Thanks for the PR. This has since landed via #2767. I'm closing this out as part of a backlog cleanup now that v2 is out. Feel free to reopen if this is still relevant. |
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
Motivation
Part of #1678
The Streamable HTTP test fixtures launch servers via multiprocessing.Process. Since coverage.py cannot track code in child processes by default, server-side code paths appear uncovered despite being exercised by tests, requiring # pragma: no cover workarounds in both test and source files.
Changes
Test refactoring
Replace multiprocessing.Process with in-process threading.Thread + uvicorn.Server for the three main server fixtures (basic_server, json_server, resumable_server). coverage.py tracks all threads in the same process by default, so these code paths are now properly covered.
Source file pragma adjustment
Since the test servers now run in-process, coverage.py now tracks source code that was previously unreachable. This requires adjusting coverage annotations to satisfy both coverage --fail-under=100 and strict-no-cover:
Files modified (annotation changes only, no logic changes):
Results