mirror of
https://github.com/home-assistant/core.git
synced 2026-12-02 11:33:11 -04:00
Publish pytest package on PyPI (#190049)
This commit is contained in:
+1
-1
@@ -138,7 +138,7 @@ tests: &tests
|
||||
- codecov.yaml
|
||||
- packages/hassfest/**
|
||||
- packages/pylint-home-assistant/**
|
||||
- packages/pytest-home-assistant/**
|
||||
- packages/pytest-homeassistant/**
|
||||
- requirements_test_pre_commit.txt
|
||||
- requirements_test.txt
|
||||
- tests/*.py
|
||||
|
||||
@@ -56,7 +56,7 @@ runs:
|
||||
RUNNER_OS: ${{ runner.os }}
|
||||
RUNNER_ARCH: ${{ runner.arch }}
|
||||
PYTHON_VERSION: ${{ steps.python.outputs.python-version }}
|
||||
HASH_FILES: ${{ hashFiles('requirements.txt', 'requirements_all.txt', 'requirements_test.txt', 'homeassistant/package_constraints.txt', 'packages/pytest-home-assistant/pyproject.toml') }}
|
||||
HASH_FILES: ${{ hashFiles('requirements.txt', 'requirements_all.txt', 'requirements_test.txt', 'homeassistant/package_constraints.txt', 'packages/pytest-homeassistant/pyproject.toml') }}
|
||||
run: |
|
||||
partial_key="${RUNNER_OS}-${RUNNER_ARCH}-${PYTHON_VERSION}-uv-"
|
||||
echo "partial_key=${partial_key}" >> $GITHUB_OUTPUT
|
||||
@@ -102,7 +102,7 @@ runs:
|
||||
python --version
|
||||
uv pip install -r requirements.txt
|
||||
uv pip install -r requirements_all.txt -r requirements_test.txt
|
||||
uv pip install -e . -e packages/hassfest -e packages/pytest-home-assistant --config-settings editable_mode=compat
|
||||
uv pip install -e . -e packages/hassfest -e packages/pytest-homeassistant --config-settings editable_mode=compat
|
||||
- name: Prune uv cache
|
||||
if: inputs.save == 'true' && steps.cache-venv.outputs.cache-hit != 'true'
|
||||
shell: bash
|
||||
|
||||
@@ -506,6 +506,8 @@ jobs:
|
||||
# when build locally for testing!
|
||||
pip install build
|
||||
python -m build
|
||||
python3 -m packages.package_release
|
||||
python -m build packages/pytest-homeassistant --outdir dist
|
||||
|
||||
- name: Upload package to PyPI
|
||||
uses: pypa/gh-action-pypi-publish@7245906fb61fa33a13554f9d5fb856fe61758086 # v1.14.3
|
||||
|
||||
@@ -116,7 +116,7 @@ jobs:
|
||||
- name: Generate partial Python venv restore key
|
||||
id: generate_python_cache_key
|
||||
env:
|
||||
HASH_REQUIREMENTS_TEST: ${{ hashFiles('requirements_test.txt', 'requirements_test_pre_commit.txt', 'packages/pytest-home-assistant/pyproject.toml') }}
|
||||
HASH_REQUIREMENTS_TEST: ${{ hashFiles('requirements_test.txt', 'requirements_test_pre_commit.txt', 'packages/pytest-homeassistant/pyproject.toml') }}
|
||||
HASH_REQUIREMENTS: ${{ hashFiles('requirements.txt') }}
|
||||
HASH_REQUIREMENTS_ALL: ${{ hashFiles('requirements_all.txt') }}
|
||||
HASH_PACKAGE_CONSTRAINTS: ${{ hashFiles('homeassistant/package_constraints.txt') }}
|
||||
@@ -681,7 +681,7 @@ jobs:
|
||||
run: |
|
||||
. venv/bin/activate
|
||||
python --version
|
||||
pylint --jobs 0 tests packages/pytest-home-assistant/pytest_homeassistant
|
||||
pylint --jobs 0 tests packages/pytest-homeassistant/pytest_homeassistant
|
||||
- name: Run pylint (partially)
|
||||
if: needs.info.outputs.test_full_suite == 'false'
|
||||
shell: bash
|
||||
@@ -831,7 +831,7 @@ jobs:
|
||||
"${GITHUB_WORKSPACE}/packages/hassfest/tests/check_package.py"
|
||||
|
||||
build-pytest-package:
|
||||
name: Build pytest-home-assistant package
|
||||
name: Build pytest-homeassistant package
|
||||
runs-on: ubuntu-26.04
|
||||
permissions:
|
||||
contents: read
|
||||
@@ -853,12 +853,12 @@ jobs:
|
||||
uv-version: ${{ needs.info.outputs.uv_version }}
|
||||
python-version: ${{ needs.info.outputs.default_python }}
|
||||
- name: Build source distribution and wheel
|
||||
run: uv build packages/pytest-home-assistant --out-dir dist
|
||||
run: uv build packages/pytest-homeassistant --out-dir dist
|
||||
- name: Install wheel and matching Home Assistant in a clean environment
|
||||
run: |
|
||||
uv venv "${RUNNER_TEMP}/pytest-package-venv"
|
||||
uv pip install --python "${RUNNER_TEMP}/pytest-package-venv/bin/python" . dist/*.whl
|
||||
cp -R packages/pytest-home-assistant/tests/standalone "${RUNNER_TEMP}/pytest-package-tests"
|
||||
cp -R packages/pytest-homeassistant/tests/standalone "${RUNNER_TEMP}/pytest-package-tests"
|
||||
- name: Test installed package outside the checkout
|
||||
working-directory: ${{ runner.temp }}
|
||||
run: |
|
||||
|
||||
@@ -73,14 +73,14 @@ repos:
|
||||
language: script
|
||||
require_serial: true
|
||||
types_or: [python, pyi]
|
||||
files: ^(homeassistant|tests|packages/pytest-home-assistant)/.+\.(py|pyi)$
|
||||
files: ^(homeassistant|tests|packages/pytest-homeassistant)/.+\.(py|pyi)$
|
||||
- id: gen_requirements_all
|
||||
name: gen_requirements_all
|
||||
entry: script/run-in-env.sh python3 -m script.gen_requirements_all
|
||||
pass_filenames: false
|
||||
language: script
|
||||
types: [text]
|
||||
files: ^(homeassistant/.+/manifest\.json|homeassistant/brands/.+\.json|pyproject\.toml|requirements_test\.txt|packages/pytest-home-assistant/pyproject\.toml|\.pre-commit-config\.yaml|script/gen_requirements_all\.py|packages/hassfest/hassfest/requirements_util\.py)$
|
||||
files: ^(homeassistant/.+/manifest\.json|homeassistant/brands/.+\.json|pyproject\.toml|requirements_test\.txt|packages/pytest-homeassistant/pyproject\.toml|\.pre-commit-config\.yaml|script/gen_requirements_all\.py|packages/hassfest/hassfest/requirements_util\.py)$
|
||||
- id: gen_copilot_instructions
|
||||
name: gen_copilot_instructions
|
||||
entry: script/run-in-env.sh python3 -m script.gen_copilot_instructions
|
||||
|
||||
Vendored
+1
-1
@@ -148,7 +148,7 @@
|
||||
{
|
||||
"label": "Install all (test & production) Requirements",
|
||||
"type": "shell",
|
||||
"command": "uv pip install -e . -e packages/pytest-home-assistant -r requirements_all.txt -r requirements_test.txt --config-settings editable_mode=compat",
|
||||
"command": "uv pip install -e . -e packages/pytest-homeassistant -r requirements_all.txt -r requirements_test.txt --config-settings editable_mode=compat",
|
||||
"group": {
|
||||
"kind": "build",
|
||||
"isDefault": true
|
||||
|
||||
Generated
+1
-1
@@ -26,7 +26,7 @@ requirements_test.txt @home-assistant/core
|
||||
/homeassistant/util/ @home-assistant/core
|
||||
/packages/hassfest/ @home-assistant/core
|
||||
/packages/pylint-home-assistant/ @home-assistant/core
|
||||
/packages/pytest-home-assistant/ @home-assistant/core
|
||||
/packages/pytest-homeassistant/ @home-assistant/core
|
||||
/script/ @home-assistant/core
|
||||
|
||||
# Home Assistant Supervisor
|
||||
|
||||
+6
-6
@@ -59,12 +59,12 @@ RUN --mount=type=bind,source=requirements.txt,target=requirements.txt \
|
||||
uv pip install -r requirements.txt -r requirements_test.txt
|
||||
|
||||
# Bootstrap installs Core and points the editable package at the workspace.
|
||||
COPY --chown=vscode:vscode packages/pytest-home-assistant/pyproject.toml \
|
||||
packages/pytest-home-assistant/README.md \
|
||||
packages/pytest-home-assistant/LICENSE.md /home/vscode/pytest-home-assistant/
|
||||
COPY --chown=vscode:vscode packages/pytest-home-assistant/pytest_homeassistant \
|
||||
/home/vscode/pytest-home-assistant/pytest_homeassistant
|
||||
RUN uv pip install --no-deps -e /home/vscode/pytest-home-assistant \
|
||||
COPY --chown=vscode:vscode packages/pytest-homeassistant/pyproject.toml \
|
||||
packages/pytest-homeassistant/README.md \
|
||||
packages/pytest-homeassistant/LICENSE.md /home/vscode/pytest-homeassistant/
|
||||
COPY --chown=vscode:vscode packages/pytest-homeassistant/pytest_homeassistant \
|
||||
/home/vscode/pytest-homeassistant/pytest_homeassistant
|
||||
RUN uv pip install --no-deps -e /home/vscode/pytest-homeassistant \
|
||||
--config-settings editable_mode=compat
|
||||
|
||||
# Claude Code native install
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
"""Packages related to Home Assistant."""
|
||||
@@ -0,0 +1,24 @@
|
||||
"""Pin pytest-homeassistant to the Home Assistant release being published."""
|
||||
|
||||
from pathlib import Path
|
||||
import tomllib
|
||||
|
||||
PACKAGE_PATH = Path("packages/pytest-homeassistant/pyproject.toml")
|
||||
|
||||
|
||||
def main() -> None:
|
||||
"""Set the package version and pin the matching homeassistant release."""
|
||||
version = tomllib.loads(Path("pyproject.toml").read_text())["project"]["version"]
|
||||
content = PACKAGE_PATH.read_text()
|
||||
for old, new in (
|
||||
('version = "0.0.0"', f'version = "{version}"'),
|
||||
('"homeassistant",', f'"homeassistant=={version}",'),
|
||||
):
|
||||
if content.count(old) != 1:
|
||||
raise SystemExit(f"Expected exactly one {old} in {PACKAGE_PATH}")
|
||||
content = content.replace(old, new)
|
||||
PACKAGE_PATH.write_text(content)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
@@ -1,4 +1,4 @@
|
||||
# pytest-home-assistant
|
||||
# pytest-homeassistant
|
||||
|
||||
Pytest fixtures and helpers for testing Home Assistant integrations. Create a
|
||||
Home Assistant instance, mock configuration entries and external services,
|
||||
@@ -9,7 +9,7 @@ simulate events, and check integration behavior.
|
||||
Install the package into your custom integration's virtual environment:
|
||||
|
||||
```shell
|
||||
uv pip install pytest-home-assistant
|
||||
uv pip install pytest-homeassistant
|
||||
```
|
||||
|
||||
Use the package release that matches your Home Assistant version. Upgrade them
|
||||
@@ -96,7 +96,7 @@ shared configuration if it exists, or provides an empty temporary directory.
|
||||
|
||||
## Migrating from pytest-homeassistant-custom-component
|
||||
|
||||
Replace the old package dependency with `pytest-home-assistant` and change imports
|
||||
Replace the old package dependency with `pytest-homeassistant` and change imports
|
||||
of `pytest_homeassistant_custom_component` to `pytest_homeassistant`. Existing
|
||||
`hass`, `enable_custom_integrations`, registry, HTTP, recorder, and snapshot
|
||||
fixtures keep their names.
|
||||
+1
-1
@@ -3,7 +3,7 @@ requires = ["setuptools>=78.0"]
|
||||
build-backend = "setuptools.build_meta"
|
||||
|
||||
[project]
|
||||
name = "pytest-home-assistant"
|
||||
name = "pytest-homeassistant"
|
||||
version = "0.0.0"
|
||||
license = "Apache-2.0"
|
||||
license-files = ["LICENSE.md"]
|
||||
+1
-1
@@ -415,7 +415,7 @@ per-file-ignores = [
|
||||
# use-implicit-booleaness-not-comparison: Tests need to validate that a list
|
||||
# or a dict is returned
|
||||
"tests/**:redefined-outer-name,use-implicit-booleaness-not-comparison",
|
||||
"packages/pytest-home-assistant/**:redefined-outer-name,use-implicit-booleaness-not-comparison",
|
||||
"packages/pytest-homeassistant/**:redefined-outer-name,use-implicit-booleaness-not-comparison",
|
||||
]
|
||||
|
||||
[tool.pylint.REPORTS]
|
||||
|
||||
+1
-1
@@ -14,7 +14,7 @@ echo "Installing development dependencies..."
|
||||
uv pip install \
|
||||
-e . \
|
||||
-e packages/hassfest \
|
||||
-e packages/pytest-home-assistant \
|
||||
-e packages/pytest-homeassistant \
|
||||
-r requirements_all.txt \
|
||||
-r requirements_test.txt \
|
||||
colorlog \
|
||||
|
||||
@@ -266,7 +266,7 @@ GENERATED_MESSAGE = (
|
||||
f"# Automatically generated by {Path(__file__).name}, do not edit\n\n"
|
||||
)
|
||||
|
||||
PYTEST_PACKAGE_PATH = Path("packages/pytest-home-assistant/pyproject.toml")
|
||||
PYTEST_PACKAGE_PATH = Path("packages/pytest-homeassistant/pyproject.toml")
|
||||
|
||||
MAP_HOOK_ID_TO_PACKAGE = {
|
||||
"ruff-check": "ruff",
|
||||
|
||||
@@ -32,7 +32,7 @@ requirements_test.txt @home-assistant/core
|
||||
/homeassistant/util/ @home-assistant/core
|
||||
/packages/hassfest/ @home-assistant/core
|
||||
/packages/pylint-home-assistant/ @home-assistant/core
|
||||
/packages/pytest-home-assistant/ @home-assistant/core
|
||||
/packages/pytest-homeassistant/ @home-assistant/core
|
||||
/script/ @home-assistant/core
|
||||
|
||||
# Home Assistant Supervisor
|
||||
|
||||
Reference in New Issue
Block a user