Skip to content

test(mcp): MCP, toolset and tool tests are named by behavior - #3872

Merged
dan-petty merged 4 commits into
mainfrom
test/1330-mcp-test-files-by-behavior
Nov 7, 2026
Merged

dan-petty merged 4 commits into
mainfrom
test/1330-mcp-test-files-by-behavior

Conversation

@dan-petty

Copy link
Copy Markdown
Owner

MCP, toolset and tool tests now sit in files that carry the name of the behavior they prove. Before, a few large files (test_mcp.py, test_fastmcp_contracts.py, test_pydantic_ai_toolsets.py) held many unrelated behaviors. A reader had to open them to learn what they cover.

The change splits those files by behavior, moves the toolset tests to tests/ai/toolsets/, and moves the MCP command tests to tests/commands/. It adds tests/support/mcp_client.py for the shared in-process client. It moves test bodies only and adds no test. Plans and documents that named an old file now name the new one.

Closes #3765

Change: openspec/changes/archive/2026-11-06-3765-mcp-test-files-by-behavior/

@dan-petty dan-petty added type/test Type test: a new or changed test scope/mcp Model Context Protocol tools, system resources, and prompts labels Nov 7, 2026
@dan-petty

Copy link
Copy Markdown
Owner Author

Test and check results (local):

  • Full devops ci on the final code (before the rebase onto the last two main commits): 20144 passed. Two known host failures, and both fail the same way on origin/main: test_mark_only_commands_under_global_dry_run and the popeye executor contract test [direct].
  • After the rebase: ruff, format and 1378 tests pass in tests/ai/mcp, tests/ai/toolsets, tests/ai/agents, tests/commands (MCP files), tests/invariants, tests/docs and tests/scaffold.
  • The rebase met a conflict with feat(cli): scaffold a command and a test to project form #3868, which cut the hand-written exclusion list from test_mcp.py. The same cut now sits in test_mcp_exposure_table.py.

Follow-up, not in this pull request: some moved test bodies still patch devops_cli names or import private names. The old files held the same sites, and this item adds none. Item #1336 owns them.

@dan-petty
dan-petty force-pushed the test/1330-mcp-test-files-by-behavior branch from 6d5f156 to f36c96b Compare November 7, 2026 00:32
Split test_fastmcp_contracts.py and test_mcp.py into one file per behavior,
rename the dispatcher, toolset and tool test files, and move the cases of
devops mcp to tests/commands. All 279 tests keep their names and bodies.
Add a syrupy snapshot of the MCP tool listing (name, description and input
schema of each tool). Fix the old paths in docs/TESTING.md, the hermetic floor
invariant and the plans of open changes.

Plans #3765.
@dan-petty
dan-petty force-pushed the test/1330-mcp-test-files-by-behavior branch from f36c96b to b0e4c52 Compare November 7, 2026 00:42
@dan-petty

Copy link
Copy Markdown
Owner Author

Fix: the first run failed in shards 1 and 4. tests/ai/mcp/conftest.py imported devops-cli at its top. pytest loads a conftest of a named test directory before it isolates HOME, so devops-cli bound its config path under the real HOME. The conftest now imports the fake for its annotation only.

@dan-petty
dan-petty marked this pull request as ready for review November 7, 2026 00:48
@dan-petty
dan-petty merged commit 2475fa2 into main Nov 7, 2026
23 checks passed
@dan-petty
dan-petty deleted the test/1330-mcp-test-files-by-behavior branch November 7, 2026 00:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

scope/mcp Model Context Protocol tools, system resources, and prompts type/test Type test: a new or changed test

Projects

None yet

Development

Successfully merging this pull request may close these issues.

test(mcp): name and split the MCP tests by behaviour

1 participant