Skip to content

Fix otbr flaky config flow tests in Python 3.14.3#169348

Merged
sairon merged 1 commit into
devfrom
fix-otbr-flaky-config-flow-tests
Apr 28, 2026
Merged

Fix otbr flaky config flow tests in Python 3.14.3#169348
sairon merged 1 commit into
devfrom
fix-otbr-flaky-config-flow-tests

Conversation

@epenet
Copy link
Copy Markdown
Contributor

@epenet epenet commented Apr 28, 2026

Breaking change

Proposed change

Spotted in https://github.com/home-assistant/core/actions/runs/25039807993/job/73341207506?pr=162263 and needed for #162263.

The tests test_hassio_discovery_flow_router_not_setup and test_hassio_discovery_flow_router_not_setup_has_preferred fail under Python 3.14.3 with:

AttributeError: 'ConfigEntry' object has no attribute 'runtime_data'

Both tests use the multiprotocol URL http://core-silabs-multiprotocol:8081 and patch async_setup_entry to return True without setting runtime_data. When the flow exercises the _set_dataset path it calls get_allowed_channel, which lazily initializes the MultiprotocolAddonManager. Once otbr's component_loaded event fires, the manager's platform callback iterates loaded entries and dereferences config_entry.runtime_data — which the mock never set — raising the AttributeError.

Fix by adding the existing multiprotocol_addon_manager_mock fixture (already used by test_hassio_discovery_flow_router_not_setup_has_preferred_2) so the manager singleton is pre-installed and the platform discovery callback never runs.

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

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][dev-checklist]
  • I have followed the [perfect PR recommendations][perfect-pr]
  • 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:

  • Documentation added/updated for [www.home-assistant.io][docs-repository]

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

  • The [manifest file][manifest-docs] 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.

🤖 Generated with Claude Code

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings April 28, 2026 08:38
@home-assistant home-assistant Bot added cla-signed code-quality has-tests integration: otbr small-pr PRs with less than 30 lines. Top 200 Integration is ranked within the top 200 by usage Quality Scale: No score labels Apr 28, 2026
@home-assistant
Copy link
Copy Markdown
Contributor

Hey there @home-assistant/core, mind taking a look at this pull request as it has been labeled with an integration (otbr) you are listed as a code owner for? Thanks!

Code owner commands

Code owners of otbr 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 otbr 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.

@epenet epenet marked this pull request as ready for review April 28, 2026 08:38
@epenet epenet requested a review from a team as a code owner April 28, 2026 08:38
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 fixes flaky OTBR config flow tests on Python 3.14.3 by ensuring the Silicon Labs Multiprotocol add-on manager is pre-seeded in hass.data, preventing a late platform callback from accessing missing ConfigEntry.runtime_data in a mocked setup path.

Changes:

  • Add the existing multiprotocol_addon_manager_mock fixture to two hassio discovery flow tests to avoid lazy manager initialization side effects.

@sairon sairon merged commit 7dacd00 into dev Apr 28, 2026
37 checks passed
@sairon sairon deleted the fix-otbr-flaky-config-flow-tests branch April 28, 2026 09:22
@github-actions github-actions Bot locked and limited conversation to collaborators Apr 29, 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: otbr Quality Scale: No score 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.

3 participants