Skip to content

vNext: Run the test suite on Home Assistant 2026.11 with pytest-homeassistant - #578

Merged
RobHofmann merged 4 commits into
5.0-devfrom
fix/pytest-homeassistant
Nov 15, 2026
Merged

RobHofmann merged 4 commits into
5.0-devfrom
fix/pytest-homeassistant

Conversation

@RobHofmann

@RobHofmann RobHofmann commented Nov 15, 2026 •

Copy link
Copy Markdown
Owner

Why

The suite was pinned to Home Assistant 2026.10, while the component needs 2026.11 (hacs.json). The reason: pytest-homeassistant-custom-component never shipped a 2026.11 build. It stopped at 2026.10.4, and its README now says it is deprecated and points to pytest-homeassistant, which home-assistant/core publishes from packages/pytest-homeassistant, one release per Home Assistant release.

Since #570 the climate entity uses the native temperature members that came in 2026.11. So on the 2026.10 pin, no test could check the climate entity through Home Assistant. This PR moves the suite to 2026.11.1.

Changes

  • requirements_dev.txt: pytest-homeassistant-custom-component==0.13.371 becomes pytest-homeassistant==2026.11.1. The new package pins Home Assistant, pytest and pytest-asyncio.
  • tests/config_flow/test_registry_lookup.py: import MockConfigEntry from pytest_homeassistant.common.
  • pytest.ini:
    • addopts = -p no:respx, as the package README asks, so Home Assistant can install its httpx alias before respx is imported.
    • Two narrow filterwarnings ignores for import-time DeprecationWarnings from code outside this repo: aiohttp on the HomeAssistantApplication subclass, and asyncio.iscoroutinefunction in the backoff package (filtered on that module only). Without either one, the suite fails at import under error.
  • tests/config_flow/conftest.py: drop the enable_custom_integrations fixture. The new hass fixture loads custom integrations by default (custom_integrations_enabled returns True and does the same hass.data.pop(loader.DATA_CUSTOM_COMPONENTS)).
  • Comments and docs that named the old plugin: pytest.ini, both conftest.py files, docs/development.md and the run-tests skill.

Requirement files and the devcontainer

The devcontainer installs Home Assistant core from the dev branch, then requirements_dev.txt with --upgrade. The exact pins in that file clashed with what core pins, and the old plugin pinned homeassistant==2026.10.0, so the install broke after a core update.

  • requirements_dev.txt now lists the tools and libraries with no version pins. --upgrade stays.
  • setup-ha-core.sh installs pytest-homeassistant right after the core, so the "Update Home Assistant to latest dev branch" task does it too. It installs it as editable from .ha-core/packages/pytest-homeassistant. That copy depends on homeassistant with no version. The copy on PyPI pins one release and would replace the core.
  • The new requirements_test.txt is -r requirements_dev.txt plus the exact pins: pytest-homeassistant==2026.11.1 and ruff==0.17.0 (same as lint.yml). CI (validate.yaml) and plain runs outside the devcontainer install it, so every run tests the same versions.
  • CONTRIBUTING.md, docs/development.md and the run-tests skill point to requirements_test.txt for plain runs.

Because the tools are unpinned and --upgrade stays, the devcontainer gets the newest Ruff, pylint and mypy, which can be newer than the versions in CI.

Testing

  • Full suite on Python 3.14 (python:3.14-slim) after pip install -r requirements_test.txt, the same install CI does: 390 passed, with Home Assistant 2026.11.1, pytest-homeassistant 2026.11.1 and Ruff 0.17.0.
  • Devcontainer: not rebuilt here, because the build needs the full Home Assistant core install. Please rebuild it once to check the editable install.
  • Each warning ignore checked on its own: removing it makes the run fail on that warning.
  • ruff check and ruff format --check: pass.

Notes

pytest-homeassistant-custom-component stopped at Home Assistant 2026.10.4
and is now deprecated upstream. The suite was pinned to 2026.10, below the
2026.11 floor of the component, so the climate entity, which uses the native
temperature members of 2026.11, could not be tested through Home Assistant.

Replace it with pytest-homeassistant 2026.11.1, which home-assistant/core
publishes from packages/pytest-homeassistant, one release per Home
Assistant release.

- Import MockConfigEntry from pytest_homeassistant.common.
- Switch off the respx pytest plugin, as the package README asks.
- Ignore two import-time DeprecationWarnings from code outside this repo:
  aiohttp on the HomeAssistantApplication subclass, and
  asyncio.iscoroutinefunction in the backoff package.
- Drop the enable_custom_integrations fixture: the new hass fixture loads
  custom integrations by default.
- Update the comments and docs that named the old plugin.

390 passed on Python 3.14 with Home Assistant 2026.11.1.
The devcontainer installs Home Assistant core from the dev branch, then
requirements_dev.txt on top. Its exact pins clashed with what that core
pins, and the old test plugin pinned homeassistant==2026.10.0, so the
install broke after a core update.

- requirements_dev.txt lists the tools and libraries with no pins, so they
  follow the core in the devcontainer. It keeps --upgrade.
- The devcontainer installs pytest-homeassistant from
  .ha-core/packages/pytest-homeassistant. That copy has no Home Assistant
  pin. The copy on PyPI pins one release and would replace the core.
- New requirements_test.txt adds the exact pins (pytest-homeassistant
  2026.11.1 and Ruff 0.17.0) on top of requirements_dev.txt. CI and plain
  runs outside the devcontainer install it, so each run tests the same
  versions.

390 passed on Python 3.14 with pip install -r requirements_test.txt.
Comment thread .devcontainer/postCreate.sh Outdated
echo "==> Installing pytest-homeassistant from the Home Assistant core checkout"
# The copy on PyPI pins one Home Assistant release and would replace the
# core installed above. This copy has no pin, so it matches that core.
python -m pip install --editable "$HA_SRC_DIR/packages/pytest-homeassistant"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Move this to setup-ha-core.sh so that the Task also installs it when called separately.

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

Moved to setup-ha-core.sh, right after the core install, so the Update task installs it too (2dfd222).

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

Same flags as the core install now: --upgrade --no-cache-dir and editable_mode=compat (9065caa). Could you rebuild the devcontainer once to confirm?

The task that updates Home Assistant to the latest dev branch runs
setup-ha-core.sh on its own. With the plugin installed there, right after
the core, that task keeps the two in step too.
Use --upgrade, --no-cache-dir and editable_mode=compat, as the core
install above it does.
@RobHofmann
RobHofmann merged commit 4fd11b8 into 5.0-dev Nov 15, 2026
4 checks passed
@RobHofmann
RobHofmann deleted the fix/pytest-homeassistant branch November 15, 2026 15:13
Twintop added a commit to Twintop/HomeAssistant-GreeClimateComponent that referenced this pull request Nov 15, 2026
A target that was stored in the other unit is converted with
TemperatureConverter and UNITS_GREE_TO_HA, as in climate.py and number.py,
and then rounded to the steps of the device. Every target in range gives
the same result as before, in both directions.

5.0-dev tests on Home Assistant 2026.11 since RobHofmann#578, so the climate tests of
the memory no longer skip.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants