@@ -28,6 +28,24 @@ This document contains critical information about working with this codebase. Fo
2828 - Bug fixes require regression tests
2929 - IMPORTANT: The ` tests/client/test_client.py ` is the most well designed test file. Follow its patterns.
3030 - IMPORTANT: Be minimal, and focus on E2E tests: Use the ` mcp.client.Client ` whenever possible.
31+ - Coverage: CI requires 100% (` fail_under = 100 ` , ` branch = true ` ).
32+ - Full check: ` ./scripts/test ` (~ 20s, matches CI exactly)
33+ - Targeted check while iterating:
34+
35+ ``` bash
36+ uv run --frozen coverage erase
37+ uv run --frozen coverage run -m pytest tests/path/test_foo.py
38+ uv run --frozen coverage combine
39+ uv run --frozen coverage report --include=' src/mcp/path/foo.py' --fail-under=0
40+ ```
41+
42+ Partial runs can' t hit 100% (coverage tracks `tests/` too), so `--fail-under=0`
43+ and `--include` scope the report to what you actually changed.
44+ - Avoid `anyio.sleep()` with a fixed duration to wait for async operations. Instead:
45+ - Use `anyio.Event` — set it in the callback/handler, `await event.wait()` in the test
46+ - For stream messages, use `await stream.receive()` instead of `sleep()` + `receive_nowait()`
47+ - Exception: `sleep()` is appropriate when testing time-based features (e.g., timeouts)
48+ - Wrap indefinite waits (`event.wait()`, `stream.receive()`) in `anyio.fail_after(5)` to prevent hangs
3149
3250Test files mirror the source tree: `src/mcp/client/streamable_http.py` → `tests/client/test_streamable_http.py`
3351Add tests to the existing file for that module.
0 commit comments