test_a_capture_on_one_thread_leaves_another_threads_output_alone¶
Tests › tests/test_mcp_server.py
What this test is for
Why it exists
The build runs on a worker thread while the transport thread writes JSON-RPC frames, so the capture has to be scoped to the thread that opened it. A capture implemented as a module-level rebind would silence the other thread; a log handler added to the shared `clew` logger would swallow the other thread's records into this build's result.
Verifies REQ-DDB-MCP-001 REQ-DDB-MCP-003 REQ-DDB-QUERY-006 REQ-DDB-QUERY-008 REQ-DDB-QUERY-009
Given
holding = threading.Event()release = threading.Event()held: dict[str, str] = {}
When
def _hold() -> None: with _common.captured_output() as buffer: holding.set() release.wait(5) held["text"] = buffer.getvalue()thread = threading.Thread(target=_hold)thread.start()try: assert holding.wait(5), "the holding thread never entered the capture" with _captured_stdout() as elsewhere: _common.active_console().print("frame from another thread") _common.logger.warning("log from another thread") finally: release.set() thread.join(5)
Then
- ✓ elsewhere.getvalue() contains "frame from another thread"
- ✓ held["text"] equals ""
tests/test_mcp_server.py:987 · its file's page
What it checks (3)
assert holding.wait(5), "the holding thread never entered the capture"not attributedassert "frame from another thread" in elsewhere.getvalue()not attributedassert held["text"] == "", f"the other thread's output was swallowed: {held['text']!r}"not attributed
Where the product reaches it
No product flow reaches this code: no product entry point's flow calls any of the functions this test calls.
Call flow
What it reaches
Each row runs from this test, through the calls it makes, to the code a requirement names. If that code breaks, the test's checks are what should catch it. Reaching is not proving: a check only proves what it observes. No mutation records were given, so these rows say what the test REACHES.
Requirements it verifies (5)
| requirement | linked by | implementers exercised |
|---|---|---|
| REQ-DDB-MCP-001 | catalog | unknown |
| REQ-DDB-MCP-003 | catalog | unknown |
| REQ-DDB-QUERY-006 | catalog | unknown |
| REQ-DDB-QUERY-008 | catalog | unknown |
| REQ-DDB-QUERY-009 | catalog | unknown |