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.
hass
from tests.common import MockConfigEntry
from pytest_homeassistant_custom_component.common import MockConfigEntry
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)
recorder_mock
, need to be initialized before enable_custom_integrations
. See https://github.com/MatthewFlamm/pytest-homeassistant-custom-component/issues/132.asyncio_mode = auto
config, see #129.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
simple_integration
in this repository.This repository is set up to be nearly fully automatic.
ha_version
, pytest_homeassistant_custom_component.const
, and in the README above.pytest_homeassistant_custom_component
files. CI testing will automatically generate the new files.This package was inspired by pytest-homeassistant by @boralyl, but is intended to more closely and automatically track the home-assistant/core library.