Skip to main content

Experimental package to automatically extract test plugins for Home Assistant custom components

Project description

pytest-homeassistant-custom-component

HA core version

Open in Gitpod

Package to automatically extract testing plugins from Home Assistant for custom component testing. The goal is to provide the same functionality as the tests in home-assistant/core. pytest-homeassistant-custom-component is updated daily according to the latest homeassistant release including beta.

Usage:

  • All pytest fixtures can be used as normal, like hass
  • For helpers:
    • home-assistant/core native test: from tests.common import MockConfigEntry
    • custom component test: from pytest_homeassistant_custom_component.common import MockConfigEntry
  • If your integration is inside a custom_components folder, a custom_components/__init__.py file or changes to sys.path may be required.
  • enable_custom_integrations fixture is required (versions >=2021.6.0b0)
  • pytest-asyncio might now require asyncio_mode = auto config, see #129.
  • If using load_fixture, the files need to be in a fixtures folder colocated with the tests. For example, a test in test_sensor.py can load data from some_data.json using load_fixture from this structure:
tests/
   fixtures/
      some_data.json
   test_sensor.py

Examples:

More Info

This repository is set up to be nearly fully automatic.

  • Version of home-assistant/core is given in ha_version, pytest_homeassistant_custom_component.const, and in the README above.
  • This package is generated against published releases of homeassistant and updated daily.
  • PRs should not include changes to the pytest_homeassistant_custom_component files. CI testing will automatically generate the new files.

Version Strategy

  • When changes in extraction are required, there will be a change in the minor version.
  • A change in the patch version indicates that it was an automatic update with a homeassistant version.
  • This enables tracking back to which versions of pytest-homeassistant-custom-component can be used for extracting testing utilities from which version of homeassistant.

This package was inspired by pytest-homeassistant by @boralyl, but is intended to more closely and automatically track the home-assistant/core library.

Project details


Release history Release notifications | RSS feed

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

File details

Details for the file pytest_homeassistant_custom_component-0.13.177.tar.gz.

File metadata

File hashes

Hashes for pytest_homeassistant_custom_component-0.13.177.tar.gz
Algorithm Hash digest
SHA256 0783c88738c3165618b0aae7a73b0c6afc4913592972d8f69da9c4e87148972d
MD5 db273ecd3588838fa8bedfad60a9e414
BLAKE2b-256 758e51a95c7dc0625d4662c9bd38d08e2fc521c5f8995b90476f6bdc6a164983

See more details on using hashes here.

File details

Details for the file pytest_homeassistant_custom_component-0.13.177-py3-none-any.whl.

File metadata

File hashes

Hashes for pytest_homeassistant_custom_component-0.13.177-py3-none-any.whl
Algorithm Hash digest
SHA256 8f535f1e707283f7af5f3b20fb22cca757f0784f9b03d67b1ef2b7f91d1f8609
MD5 470426130719b8aea0362764da56ecbe
BLAKE2b-256 026543e25785ce600b7959e0ad70218b03a351cea1d7050607de250b1ed4b6cd

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page