Conversation
… old Co-authored-by: dhalperi <526415+dhalperi@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix MCP integration tests for optional dependency
Skip MCP integration tests when Mar 16, 2026
mcp is not installed or versions predate MCP support
dhalperi
reviewed
Mar 16, 2026
Member
dhalperi
left a comment
There was a problem hiding this comment.
@dhalperi reviewed 1 file and all commit messages.
Reviewable status:complete! all files reviewed, all discussions resolved (waiting on copilot[bot]).
Member
|
@copilot fix failures. |
…arty Co-authored-by: dhalperi <526415+dhalperi@users.noreply.github.com>
auto-merge was automatically disabled
March 16, 2026 20:45
Head branch was pushed to by a user without write access
Contributor
Author
dhalperi
reviewed
Mar 16, 2026
Member
dhalperi
left a comment
There was a problem hiding this comment.
@dhalperi reviewed 1 file and all commit messages.
Reviewable status:complete! all files reviewed, all discussions resolved (waiting on copilot[bot]).
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #972 +/- ##
=======================================
Coverage 87.77% 87.77%
=======================================
Files 26 26
Lines 3763 3763
Branches 501 501
=======================================
Hits 3303 3303
Misses 330 330
Partials 130 130 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
pytest.importorskip("mcp")at module level intests/integration/test_mcp_server.pyto prevent collection failure whenmcpis not installed_require_versionsusingskip_old_versionto skip tests if pybatfish/batfish version <2026.3.16import pytest(third-party) beforeimport pybatfish(first-party) with blank line separatorOriginal prompt
Create a PR in
batfish/pybatfishto prevent the new MCP integration tests from failing when the optionalmcpdependency is not installed and when cross-version workflows run HEAD tests against older released Pybatfish versions.Context:
batfish/docker(Cross-Version Tests and Upload) runs integration tests from apybf_testsartifact (built from HEAD) against various installed Pybatfish versions (e.g.,pip install pybatfish[dev]==<old>). This caused pytest collection to fail becausetests/integration/test_mcp_server.pyimportsmcp.server.fastmcp.FastMCPat module import time, producingModuleNotFoundError: No module named 'mcp'.tests/common_util.pywith helperrequires_bf(version)decorator that skips tests if either Batfish or Pybatfish version is older than a minimum.Requested change:
Update the new MCP integration test module (
tests/integration/test_mcp_server.py, or wherever MCP tests were added) to:mcpat module import time in a way that fails collection whenmcpis not installed.@requires_bf(...)decorator.mcpis not installed (usepytest.importorskip('mcp', reason=...)or equivalent). Ensure the skip happens before anymcpimports.Ensure any version string used matches the project’s version format expectations (e.g.,
YYYY.MM.DDorYYYY.MM.DD.####). The user requested using today’s date (current date: 2026-03-16) as the minimum version, so use2026.03.16(or include a patch segment if needed by existing logic) consistently.Make the change minimal and targeted:
pytestcollection succeeds even withoutmcpinstalled.Acceptance criteria:
pytest tests/integrationin an environment withoutmcpinstalled does not error during collection; MCP-related tests are skipped with a clear reason.mcpis installed and versions are >= 2026.03.16 proceeds normally.mcp.Repository: batfish/pybatfish
The following is the prior conversation context from the user's chat exploration (may be truncated):
User: We just added the mcp support to the head development version of pybatfish. Why would this failing test be running on our old version, and what do we need to do to fix it? It also seems odd that it's running integration tests from the head version of pybf instead of the version it installed?
Assistant: This failure is happening because the cross-version workflow in
batfish/dockerdeliberately runs “HEAD” integration tests against released/older Pybatfish installs—and your new MCP integration test now importsmcp, which isn’t present in those older releases’ dependency sets.Why is it running on an “old version” of pybatfish?
In
batfish/docker’s reusable workflow, thepybf_cross_version_testsjob installs Pybatfish from PyPI at specific historical versions:So it’s expected to be running tests while
pybatfish==<old-version>is installed.Why does it seem to run HEAD integration tests instead of the installed version?
Also by design: the workflow downloads the
pybf_testsartifact (which comes from the HEAD build) and runs those tests regardless of which Pybatfish version is installed:That’s why you’re seeing
tests/integration/test_mcp_server.pyfrom HEAD being collected, even though the installed package is an olderpybatfish.What exactly is failing?
Your failing job log shows test collection fails because
mcpisn’t installed:What you need to do to fix it
You have two viable options (pick base...
This pull request was created from Copilot chat.
📱 Kick off Copilot coding agent tasks wherever you are with GitHub Mobile, available on iOS and Android.