Metadata-Version: 2.4
Name: pytest-homeassistant-custom-component-framework
Version: 1.0.18
Summary: Experimental package to automatically extract test plugins for Home Assistant custom components
Home-page: https://github.com/SukramJ/pytest-homeassistant-custom-component
Author: Matthew Flamm, SukramJ
Author-email: matthewflamm0@gmail.com, sukramj@icloud.com
License: MIT license
Classifier: Development Status :: 3 - Alpha
Classifier: Framework :: Pytest
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3.14
Classifier: Topic :: Software Development :: Testing
Requires-Python: >=3.14
Description-Content-Type: text/markdown
License-File: LICENSE
License-File: LICENSE_HA_CORE.md
Requires-Dist: sqlalchemy
Requires-Dist: coverage==7.13.5
Requires-Dist: freezegun==1.5.5
Requires-Dist: license-expression==30.4.3
Requires-Dist: mock-open==1.4.0
Requires-Dist: pydantic==2.13.2
Requires-Dist: pylint-per-file-ignores==3.2.1
Requires-Dist: pipdeptree==2.26.1
Requires-Dist: pytest-asyncio==1.3.0
Requires-Dist: pytest-aiohttp==1.1.0
Requires-Dist: pytest-cov==7.1.0
Requires-Dist: pytest-freezer==0.4.9
Requires-Dist: pytest-github-actions-annotate-failures==0.4.0
Requires-Dist: pytest-socket==0.7.0
Requires-Dist: pytest-sugar==1.1.1
Requires-Dist: pytest-timeout==2.4.0
Requires-Dist: pytest-unordered==0.7.0
Requires-Dist: pytest-picked==0.5.1
Requires-Dist: pytest-xdist==3.8.0
Requires-Dist: pytest==9.0.3
Requires-Dist: requests-mock==1.12.1
Requires-Dist: respx==0.23.1
Requires-Dist: syrupy==5.1.0
Requires-Dist: tqdm==4.67.1
Requires-Dist: homeassistant==2026.5.0
Requires-Dist: SQLAlchemy==2.0.49
Requires-Dist: paho-mqtt==2.1.0
Requires-Dist: numpy==2.3.2
Requires-Dist: aiohasupervisor==0.4.3
Dynamic: author
Dynamic: author-email
Dynamic: classifier
Dynamic: description
Dynamic: description-content-type
Dynamic: home-page
Dynamic: license
Dynamic: license-file
Dynamic: requires-dist
Dynamic: requires-python
Dynamic: summary

# pytest-homeassistant-custom-component

![HA core version](https://img.shields.io/static/v1?label=HA+core+version&message=2026.5.0&labelColor=blue)

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)
  * Some fixtures, e.g. `recorder_mock`, need to be initialized before `enable_custom_integrations`. See https://github.com/MatthewFlamm/pytest-homeassistant-custom-component/issues/132.
* 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
```

* When using syrupy snapshots, add a `snapshot` fixture to conftest.py to make sure the snapshots are loaded from snapshot folder colocated with the tests.

```py
    from pytest_homeassistant_custom_component.syrupy import HomeAssistantSnapshotExtension
    from syrupy.assertion import SnapshotAssertion


    @pytest.fixture
    def snapshot(snapshot: SnapshotAssertion) -> SnapshotAssertion:
        """Return snapshot assertion fixture with the Home Assistant extension."""
        return snapshot.use_extension(HomeAssistantSnapshotExtension)
```

## Examples:
* See [list of custom components](https://github.com/MatthewFlamm/pytest-homeassistant-custom-component/network/dependents) as examples that use this package.
* Also see tests for `simple_integration` in this repository.
* Use [cookiecutter-homeassistant-custom-component](https://github.com/oncleben31/cookiecutter-homeassistant-custom-component) to create a custom component with tests by using [cookiecutter](https://github.com/cookiecutter/cookiecutter).
* The [github-custom-component-tutorial](https://github.com/boralyl/github-custom-component-tutorial) explaining in details how to create a custom componenent with a test suite using this package.

## 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](https://github.com/boralyl/pytest-homeassistant) by @boralyl, but is intended to more closely and automatically track the home-assistant/core library.
