Skip to content

Fix bang olufsen flaky tests in Python 3.14.3#169345

Merged
jbouwh merged 1 commit into
devfrom
epenet/20260428-0916
Apr 28, 2026
Merged

Fix bang olufsen flaky tests in Python 3.14.3#169345
jbouwh merged 1 commit into
devfrom
epenet/20260428-0916

Conversation

@epenet
Copy link
Copy Markdown
Contributor

@epenet epenet commented Apr 28, 2026

Proposed change

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

Follow-up to #168885 and needed for #162263

The test is flaky because media-player (which updates the friendly name of the device entry) might be initialised before OR after the other platforms.
This ensures that the "updated" friendly name matches the "initial" friendly name.

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:

Co-authored-by: Copilot <copilot@github.com>
Copilot AI review requested due to automatic review settings April 28, 2026 07:17
@home-assistant
Copy link
Copy Markdown
Contributor

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

Code owner commands

Code owners of bang_olufsen 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 bang_olufsen 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 stabilizes the Bang & Olufsen integration tests under Python 3.14.3 by ensuring the mocked get_beolink_self() response matches the specific device/config entry used in each test, preventing name/device-info drift during setup and diagnostics collection.

Changes:

  • Update Bang & Olufsen tests to explicitly mock MozartClient.get_beolink_self() for non-default devices (e.g., A5, Premiere).
  • Extend test imports to include the correct friendly name/JID constants for those devices.
  • Refresh diagnostics snapshot expectations to align with the now-deterministic device/entity friendly names.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.

Show a summary per file
File Description
tests/components/bang_olufsen/test_sensor.py Sets get_beolink_self() mock for A5 battery sensor test to match the A5 config entry identity.
tests/components/bang_olufsen/test_event.py Sets get_beolink_self() mock for Premiere/A5 event-entity creation tests to avoid name mismatches.
tests/components/bang_olufsen/test_diagnostics.py Sets get_beolink_self() mock for A5 diagnostics test and updates imported constants accordingly.
tests/components/bang_olufsen/test_binary_sensor.py Sets get_beolink_self() mock for A5 charging binary sensor test to stabilize naming.
tests/components/bang_olufsen/snapshots/test_diagnostics.ambr Updates snapshot friendly names/device info to reflect the corrected mocked self identity.

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 👍

@jbouwh jbouwh merged commit fa6c6ee into dev Apr 28, 2026
37 checks passed
@jbouwh jbouwh deleted the epenet/20260428-0916 branch April 28, 2026 07:23
@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.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants