Skip to content

Fix flaky mcp_server tests with Python 3.14.3#169385

Merged
allenporter merged 3 commits intodevfrom
epenet/20260428-1740
Apr 29, 2026
Merged

Fix flaky mcp_server tests with Python 3.14.3#169385
allenporter merged 3 commits intodevfrom
epenet/20260428-1740

Conversation

@epenet
Copy link
Copy Markdown
Contributor

@epenet epenet commented Apr 28, 2026

Proposed change

Alternative to #169385

Spotted in https://github.com/home-assistant/core/actions/runs/25057100718/job/73402201810?pr=162263

Needed for #162263

Under some circumstances, it seems that conversation can be loaded before homeassistant component has finished loading.

2026-04-28 14:14:38.268 INFO     SyncWorker_0 homeassistant.loader:loader.py:785 Loaded mcp_server from homeassistant.components.mcp_server
2026-04-28 14:14:38.270 INFO     SyncWorker_0 homeassistant.loader:loader.py:785 Loaded homeassistant from homeassistant.components.homeassistant
2026-04-28 14:14:38.271 INFO     SyncWorker_0 homeassistant.loader:loader.py:785 Loaded http from homeassistant.components.http
2026-04-28 14:14:38.272 INFO     MainThread homeassistant.setup:setup.py:393 Setting up http
2026-04-28 14:14:38.276 INFO     SyncWorker_0 homeassistant.loader:loader.py:785 Loaded conversation from homeassistant.components.conversation
2026-04-28 14:14:38.280 INFO     SyncWorker_0 homeassistant.loader:loader.py:785 Loaded intent from homeassistant.components.intent
2026-04-28 14:14:38.281 INFO     MainThread homeassistant.setup:setup.py:393 Setting up intent
2026-04-28 14:14:38.283 INFO     MainThread homeassistant.setup:setup.py:393 Setting up conversation
2026-04-28 14:14:38.284 ERROR    MainThread homeassistant.setup:setup.py:438 Error during setup of component conversation: 'homeassistant.exposed_entities'
2026-04-28 14:14:38.286 INFO     MainThread homeassistant.setup:setup.py:393 Setting up homeassistant

Type of change

  • Dependency upgrade
  • Bugfix (non-breaking change which fixes an issue)
  • New integration (thank you!)
  • New feature (which adds functionality to an existing integration)
  • Deprecation (breaking change to happen in the future)
  • Breaking change (fix/feature causing existing functionality to break)
  • Code quality improvements to existing code or addition of tests

Additional information

  • This PR fixes or closes issue: fixes #
  • This PR is related to issue:
  • Link to documentation pull request:
  • Link to developer documentation pull request:
  • Link to frontend pull request:

Checklist

  • I understand the code I am submitting and can explain how it works.
  • The code change is tested and works locally.
  • Local tests pass. Your PR cannot be merged unless tests pass
  • There is no commented out code in this PR.
  • I have followed the development checklist
  • I have followed the perfect PR recommendations
  • The code has been formatted using Ruff (ruff format homeassistant tests)
  • Tests have been added to verify that the new code works.
  • Any generated code has been carefully reviewed for correctness and compliance with project standards.

If user exposed functionality or configuration variables are added/changed:

If the code communicates with devices, web services, or third-party tools:

  • The manifest file has all fields filled out correctly.
    Updated and included derived files by running: python3 -m script.hassfest.
  • New or updated dependencies have been added to requirements_all.txt.
    Updated by running python3 -m script.gen_requirements_all.
  • For the updated dependencies a diff between library versions and ideally a link to the changelog/release notes is added to the PR description.

To help with the load of incoming pull requests:

Copilot AI review requested due to automatic review settings April 28, 2026 15:42
@epenet epenet requested a review from allenporter as a code owner April 28, 2026 15:42
@home-assistant home-assistant Bot added cla-signed code-quality has-tests integration: mcp_server small-pr PRs with less than 30 lines. Top 200 Integration is ranked within the top 200 by usage labels Apr 28, 2026
@home-assistant
Copy link
Copy Markdown
Contributor

Hey there @allenporter, mind taking a look at this pull request as it has been labeled with an integration (mcp_server) you are listed as a code owner for? Thanks!

Code owner commands

Code owners of mcp_server can trigger bot actions by commenting:

  • @home-assistant close Closes the pull request.
  • @home-assistant mark-draft Mark the pull request as draft.
  • @home-assistant ready-for-review Remove the draft status from the pull request.
  • @home-assistant rename Awesome new title Renames the pull request.
  • @home-assistant reopen Reopen the pull request.
  • @home-assistant unassign mcp_server Removes the current integration label and assignees on the pull request, add the integration domain after the command.
  • @home-assistant update-branch Update the pull request branch with the base branch.
  • @home-assistant add-label needs-more-information Add a label (needs-more-information, problem in dependency, problem in custom component, problem in config, problem in device, feature-request) to the pull request.
  • @home-assistant remove-label needs-more-information Remove a label (needs-more-information, problem in dependency, problem in custom component, problem in config, problem in device, feature-request) on the pull request.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR addresses flaky mcp_server test failures under Python 3.14.3 by ensuring the core homeassistant component is set up for all tests in the tests/components/mcp_server package.

Changes:

  • Add an autouse pytest fixture to set up the homeassistant component before tests run.

Comment thread tests/components/mcp_server/conftest.py Outdated
Updated docstring for ensure_homeassistant_loaded fixture.
Copilot AI review requested due to automatic review settings April 28, 2026 15:48
"codeowners": ["@allenporter"],
"config_flow": true,
"dependencies": ["homeassistant", "http", "conversation"],
"dependencies": ["http", "conversation"],
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In production, "homeassistant" is always loaded first. It doesn't not need to be present in dependencies so I have removed it.

CORE_INTEGRATIONS = {"homeassistant", "persistent_notification"}

Copy link
Copy Markdown
Contributor

@jbouwh jbouwh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM,
Thanks @epenet 👍

@epenet epenet mentioned this pull request Apr 29, 2026
24 tasks
@allenporter allenporter merged commit 4c70fef into dev Apr 29, 2026
33 checks passed
@allenporter allenporter deleted the epenet/20260428-1740 branch April 29, 2026 05:13
@github-actions github-actions Bot locked and limited conversation to collaborators Apr 30, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

cla-signed code-quality has-tests integration: mcp_server Quality Scale: silver small-pr PRs with less than 30 lines. Top 200 Integration is ranked within the top 200 by usage

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants