test_a_capture_on_one_thread_leaves_another_threads_output_alone

Tests › tests/test_mcp_server.py

passed Passed in the packaged run.

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

  1. holding = threading.Event()
  2. release = threading.Event()
  3. held: dict[str, str] = {}
→

When

  1. def _hold() -> None: with _common.captured_output() as buffer: holding.set() release.wait(5) held["text"] = buffer.getvalue()
  2. thread = threading.Thread(target=_hold)
  3. thread.start()
  4. 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

  1. ✓ elsewhere.getvalue() contains "frame from another thread"
  2. ✓ held["text"] equals ""

tests/test_mcp_server.py:987 · its file's page

What it checks (3)

  1. assert holding.wait(5), "the holding thread never entered the capture" not attributed
  2. assert "frame from another thread" in elsewhere.getvalue() not attributed
  3. assert 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

test_a_capture_on_one_thread_leaves_another_threads_output_alone→captured_output→active_console

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)

requirementlinked byimplementers exercised
REQ-DDB-MCP-001catalogunknown
REQ-DDB-MCP-003catalogunknown
REQ-DDB-QUERY-006catalogunknown
REQ-DDB-QUERY-008catalogunknown
REQ-DDB-QUERY-009catalogunknown